-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
7.2.1: self test is failing in testing/test_assertion.py::test_raise_assertion_error_raising_repr
unit
#10663
Comments
In case someone doesn't know, I provide a link to PEP517 |
Don't worry I'm using pep517 based buid with +99% od=f all my python modules [tkloczko@devel-g2v SPECS]$ grep pyproject_wheel -l python-*spec | wc -l ; ls -1 python-*spec |wc -l
1067
1074 Nevertheless this issue has nothing to do wih pep517. |
this is due to your custom setup -- the class you've got has a module path of |
@asottile could you please clarify what's to be done to avoid the problem? We're also seeing it with Python 3.10.7 and python-exceptiongroup 1.1.1. |
Updating to 7.3.x seems to resolve the failure. |
Just tested 7.3.1 ad I have 4 units failing + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.3.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.3.1-2.fc35.x86_64/usr/bin/pytest -ra -m 'not network' --import-mode=importlib -p no:flaky -p no:randomly
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-7.3.1
configfile: pyproject.toml
testpaths: testing
plugins: cov-4.0.0, xdist-3.2.0, hypothesis-6.71.0
collected 3420 items
testing/acceptance_test.py ..... [ 0%]
testing/deprecated_test.py ....... [ 0%]
testing/test_argcomplete.py .. [ 0%]
testing/test_assertion.py ..................................................................... [ 2%]
testing/test_assertrewrite.py ............................................ [ 3%]
testing/test_capture.py .............................................................s.. [ 5%]
testing/test_collection.py . [ 5%]
testing/test_compat.py ........... [ 5%]
testing/test_config.py ...................................................... [ 7%]
testing/test_conftest.py ........... [ 7%]
testing/test_debugging.py . [ 7%]
testing/test_doctest.py ............. [ 8%]
testing/test_entry_points.py . [ 8%]
testing/test_faulthandler.py ... [ 8%]
testing/test_findpaths.py ..............s... [ 8%]
testing/test_helpconfig.py . [ 8%]
testing/test_junitxml.py .... [ 9%]
testing/test_legacypath.py .... [ 9%]
testing/test_main.py ..... [ 9%]
testing/test_mark.py .............. [ 9%]
testing/test_mark_expression.py .................................................................................... [ 12%]
testing/test_monkeypatch.py ............................... [ 13%]
testing/test_nodes.py .............. [ 13%]
testing/test_nose.py ss [ 13%]
testing/test_parseopt.py ............................ [ 14%]
testing/test_pastebin.py .... [ 14%]
testing/test_pathlib.py .............................................s..... [ 15%]
testing/test_pluginmanager.py ......... [ 16%]
testing/test_pytester.py ..................... [ 16%]
testing/test_recwarn.py ........................................ [ 18%]
testing/test_runner.py .............. [ 18%]
testing/test_scope.py .... [ 18%]
testing/test_skipping.py . [ 18%]
testing/test_stash.py . [ 18%]
testing/test_terminal.py ....................................... [ 19%]
testing/test_tmpdir.py ...s............... [ 20%]
testing/test_warning_types.py .............. [ 20%]
testing/test_warnings.py . [ 20%]
testing/_py/test_local.py .................................................................ss..............s.................x......s.....................................sssssss.... [ 25%]
........................x... [ 26%]
testing/code/test_code.py ................. [ 26%]
testing/code/test_excinfo.py ............................................................................................................................... [ 30%]
testing/code/test_source.py ....................................................... [ 31%]
testing/freeze/tests/test_trivial.py .. [ 31%]
testing/io/test_saferepr.py .............. [ 32%]
testing/io/test_terminalwriter.py ............................................. [ 33%]
testing/io/test_wcwidth.py ................. [ 34%]
testing/logging/test_fixture.py ......... [ 34%]
testing/logging/test_formatter.py .... [ 34%]
testing/logging/test_reporting.py .. [ 34%]
testing/python/approx.py ................................................................................. [ 36%]
testing/python/collect.py .. [ 37%]
testing/python/fixtures.py .......... [ 37%]
testing/python/integration.py .... [ 37%]
testing/python/metafunc.py ......................................... [ 38%]
testing/python/raises.py ...................F... [ 39%]
testing/freeze/tests/test_doctest.txt . [ 39%]
testing/acceptance_test.py ..............................................F...x.................... [ 41%]
testing/deprecated_test.py ...........ss [ 41%]
testing/test_assertion.py ................................F.. [ 42%]
testing/test_assertrewrite.py .............s.......................................... [ 44%]
testing/test_cacheprovider.py .................................................... [ 45%]
testing/test_capture.py ......x.................................... [ 47%]
testing/test_collection.py ...........................x......................................s................. [ 49%]
testing/test_compat.py .. [ 49%]
testing/test_config.py .............x..............................................................................s................................. [ 53%]
testing/test_conftest.py .............s............................. [ 54%]
testing/test_debugging.py ............. [ 55%]
testing/test_doctest.py ..............................................................x.......................................................... [ 58%]
testing/test_error_diffs.py ............ [ 58%]
testing/test_faulthandler.py ... [ 59%]
testing/test_helpconfig.py ........ [ 59%]
testing/test_junitxml.py ............................................................................................................................. [ 62%]
testing/test_legacypath.py .......... [ 63%]
testing/test_link_resolve.py . [ 63%]
testing/test_main.py ............. [ 63%]
testing/test_mark.py ...........................................................x................ [ 65%]
testing/test_monkeypatch.py ...F [ 65%]
testing/test_nodes.py .... [ 66%]
testing/test_nose.py ssssssssssssssssssssss [ 66%]
testing/test_parseopt.py s [ 66%]
testing/test_pastebin.py ... [ 66%]
testing/test_pluginmanager.py ................ [ 67%]
testing/test_pytester.py x......................... [ 68%]
testing/test_python_path.py ..... [ 68%]
testing/test_recwarn.py .. [ 68%]
testing/test_reports.py .................. [ 68%]
testing/test_runner.py .......................x..................... [ 70%]
testing/test_runner_xunit.py ............. [ 70%]
testing/test_session.py ........................ [ 71%]
testing/test_setuponly.py .......................... [ 71%]
testing/test_setupplan.py ... [ 72%]
testing/test_skipping.py ............................................................................................ [ 74%]
testing/test_stepwise.py .............. [ 75%]
testing/test_terminal.py ................................................................................................................... [ 78%]
testing/test_threadexception.py .... [ 78%]
testing/test_tmpdir.py .................... [ 79%]
testing/test_unittest.py ....................................................................... [ 81%]
testing/test_unraisableexception.py .... [ 81%]
testing/test_warning_types.py . [ 81%]
testing/test_warnings.py ...................sss......... [ 82%]
testing/code/test_excinfo.py ....sssssssss.......... [ 83%]
testing/examples/test_issue519.py . [ 83%]
testing/logging/test_fixture.py ....... [ 83%]
testing/logging/test_reporting.py ......................................... [ 84%]
testing/python/approx.py . [ 84%]
testing/python/collect.py ........................................................................... [ 86%]
testing/python/fixtures.py .......................................................................x.................................................................................. [ 91%]
.................... [ 91%]
testing/python/integration.py ............... [ 92%]
testing/python/metafunc.py ............................................................ [ 93%]
testing/python/raises.py ... [ 94%]
testing/python/show_fixtures_per_test.py ........ [ 94%]
testing/acceptance_test.py .... [ 94%]
testing/test_assertion.py ............ [ 94%]
testing/test_assertrewrite.py ......... [ 95%]
testing/test_capture.py ........................ [ 95%]
testing/test_collection.py . [ 95%]
testing/test_compat.py . [ 95%]
testing/test_config.py .. [ 95%]
testing/test_debugging.py sssssssssss.ssssssssssssssss.sss....ssss.sss [ 97%]
testing/test_faulthandler.py ..s. [ 97%]
testing/test_helpconfig.py .. [ 97%]
testing/test_legacypath.py . [ 97%]
testing/test_meta.py ................................................................... [ 99%]
testing/test_pytester.py ....s [ 99%]
testing/test_reports.py . [ 99%]
testing/test_terminal.py ss.. [ 99%]
testing/test_unittest.py s. [ 99%]
testing/test_warnings.py ......... [ 99%]
testing/python/collect.py . [ 99%]
testing/python/fixtures.py x. [100%]
========================================================================================= FAILURES ==========================================================================================
______________________________________________________________________ TestRaises.test_raises_exception_looks_iterable ______________________________________________________________________
self = <testing.python.raises.TestRaises object at 0x7f68c62e4970>
def test_raises_exception_looks_iterable(self):
class Meta(type):
def __getitem__(self, item):
return 1 / 0
def __len__(self):
return 1
class ClassLooksIterableException(Exception, metaclass=Meta):
pass
with pytest.raises(
Failed,
match=r"DID NOT RAISE <class 'raises(\..*)*ClassLooksIterableException'>",
):
> pytest.raises(ClassLooksIterableException, lambda: None)
/home/tkloczko/rpmbuild/BUILD/pytest-7.3.1/testing/python/raises.py:264:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_exception = <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>
args = (<function TestRaises.test_raises_exception_looks_iterable.<locals>.<lambda> at 0x7f68beede670>,), kwargs = {}, __tracebackhide__ = True
expected_exceptions = (<class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>,)
exc = <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>
message = "DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>"
func = <function TestRaises.test_raises_exception_looks_iterable.<locals>.<lambda> at 0x7f68beede670>
def raises( # noqa: F811
expected_exception: Union[Type[E], Tuple[Type[E], ...]], *args: Any, **kwargs: Any
) -> Union["RaisesContext[E]", _pytest._code.ExceptionInfo[E]]:
r"""Assert that a code block/function call raises an exception.
:param typing.Type[E] | typing.Tuple[typing.Type[E], ...] expected_exception:
The expected exception type, or a tuple if one of multiple possible
exception types are expected.
:kwparam str | typing.Pattern[str] | None match:
If specified, a string containing a regular expression,
or a regular expression object, that is tested against the string
representation of the exception using :func:`re.search`.
To match a literal string that may contain :ref:`special characters
<re-syntax>`, the pattern can first be escaped with :func:`re.escape`.
(This is only used when :py:func:`pytest.raises` is used as a context manager,
and passed through to the function otherwise.
When using :py:func:`pytest.raises` as a function, you can use:
``pytest.raises(Exc, func, match="passed on").match("my pattern")``.)
.. currentmodule:: _pytest._code
Use ``pytest.raises`` as a context manager, which will capture the exception of the given
type::
>>> import pytest
>>> with pytest.raises(ZeroDivisionError):
... 1/0
If the code block does not raise the expected exception (``ZeroDivisionError`` in the example
above), or no exception at all, the check will fail instead.
You can also use the keyword argument ``match`` to assert that the
exception matches a text or regex::
>>> with pytest.raises(ValueError, match='must be 0 or None'):
... raise ValueError("value must be 0 or None")
>>> with pytest.raises(ValueError, match=r'must be \d+$'):
... raise ValueError("value must be 42")
The context manager produces an :class:`ExceptionInfo` object which can be used to inspect the
details of the captured exception::
>>> with pytest.raises(ValueError) as exc_info:
... raise ValueError("value must be 42")
>>> assert exc_info.type is ValueError
>>> assert exc_info.value.args[0] == "value must be 42"
.. note::
When using ``pytest.raises`` as a context manager, it's worthwhile to
note that normal context manager rules apply and that the exception
raised *must* be the final line in the scope of the context manager.
Lines of code after that, within the scope of the context manager will
not be executed. For example::
>>> value = 15
>>> with pytest.raises(ValueError) as exc_info:
... if value > 10:
... raise ValueError("value must be <= 10")
... assert exc_info.type is ValueError # this will not execute
Instead, the following approach must be taken (note the difference in
scope)::
>>> with pytest.raises(ValueError) as exc_info:
... if value > 10:
... raise ValueError("value must be <= 10")
...
>>> assert exc_info.type is ValueError
**Using with** ``pytest.mark.parametrize``
When using :ref:`pytest.mark.parametrize ref`
it is possible to parametrize tests such that
some runs raise an exception and others do not.
See :ref:`parametrizing_conditional_raising` for an example.
**Legacy form**
It is possible to specify a callable by passing a to-be-called lambda::
>>> raises(ZeroDivisionError, lambda: 1/0)
<ExceptionInfo ...>
or you can specify an arbitrary callable with arguments::
>>> def f(x): return 1/x
...
>>> raises(ZeroDivisionError, f, 0)
<ExceptionInfo ...>
>>> raises(ZeroDivisionError, f, x=0)
<ExceptionInfo ...>
The form above is fully supported but discouraged for new code because the
context manager form is regarded as more readable and less error-prone.
.. note::
Similar to caught exception objects in Python, explicitly clearing
local references to returned ``ExceptionInfo`` objects can
help the Python interpreter speed up its garbage collection.
Clearing those references breaks a reference cycle
(``ExceptionInfo`` --> caught exception --> frame stack raising
the exception --> current frame stack --> local variables -->
``ExceptionInfo``) which makes Python keep all objects referenced
from that cycle (including all local variables in the current
frame) alive until the next cyclic garbage collection run.
More detailed information can be found in the official Python
documentation for :ref:`the try statement <python:try>`.
"""
__tracebackhide__ = True
if not expected_exception:
raise ValueError(
f"Expected an exception type or a tuple of exception types, but got `{expected_exception!r}`. "
f"Raising exceptions is already understood as failing the test, so you don't need "
f"any special code to say 'this should never raise an exception'."
)
if isinstance(expected_exception, type):
expected_exceptions: Tuple[Type[E], ...] = (expected_exception,)
else:
expected_exceptions = expected_exception
for exc in expected_exceptions:
if not isinstance(exc, type) or not issubclass(exc, BaseException):
msg = "expected exception must be a BaseException type, not {}" # type: ignore[unreachable]
not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__
raise TypeError(msg.format(not_a))
message = f"DID NOT RAISE {expected_exception}"
if not args:
match: Optional[Union[str, Pattern[str]]] = kwargs.pop("match", None)
if kwargs:
msg = "Unexpected keyword arguments passed to pytest.raises: "
msg += ", ".join(sorted(kwargs))
msg += "\nUse context-manager form instead?"
raise TypeError(msg)
return RaisesContext(expected_exception, message, match)
else:
func = args[0]
if not callable(func):
raise TypeError(f"{func!r} object (type: {type(func)}) must be callable")
try:
func(*args[1:], **kwargs)
except expected_exception as e:
# We just caught the exception - there is a traceback.
assert e.__traceback__ is not None
return _pytest._code.ExceptionInfo.from_exc_info(
(type(e), e, e.__traceback__)
)
> fail(message)
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.3.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/python_api.py:958:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
reason = "DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>", pytrace = True, msg = None
@_with_exception(Failed)
def fail(reason: str = "", pytrace: bool = True, msg: Optional[str] = None) -> NoReturn:
"""Explicitly fail an executing test with the given message.
:param reason:
The message to show the user as reason for the failure.
:param pytrace:
If False, msg represents the full failure information and no
python traceback will be reported.
:param msg:
Same as ``reason``, but deprecated. Will be removed in a future version, use ``reason`` instead.
"""
__tracebackhide__ = True
reason = _resolve_msg_to_reason("fail", reason, msg)
> raise Failed(msg=reason, pytrace=pytrace)
E Failed: DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.3.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/outcomes.py:198: Failed
During handling of the above exception, another exception occurred:
self = <testing.python.raises.TestRaises object at 0x7f68c62e4970>
def test_raises_exception_looks_iterable(self):
class Meta(type):
def __getitem__(self, item):
return 1 / 0
def __len__(self):
return 1
class ClassLooksIterableException(Exception, metaclass=Meta):
pass
with pytest.raises(
Failed,
match=r"DID NOT RAISE <class 'raises(\..*)*ClassLooksIterableException'>",
):
> pytest.raises(ClassLooksIterableException, lambda: None)
E AssertionError: Regex pattern did not match.
E Regex: "DID NOT RAISE <class 'raises(\\..*)*ClassLooksIterableException'>"
E Input: "DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>"
/home/tkloczko/rpmbuild/BUILD/pytest-7.3.1/testing/python/raises.py:264: AssertionError
_______________________________________________________________ TestInvocationVariants.test_cmdline_python_namespace_package ________________________________________________________________
self = <testing.acceptance_test.TestInvocationVariants object at 0x7f68c73b2e20>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-8/test_cmdline_python_namespace_package0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f68bedb95e0>
def test_cmdline_python_namespace_package(
self, pytester: Pytester, monkeypatch
) -> None:
"""Test --pyargs option with namespace packages (#1567).
Ref: https://packaging.python.org/guides/packaging-namespace-packages/
"""
monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False)
search_path = []
for dirname in "hello", "world":
d = pytester.mkdir(dirname)
search_path.append(d)
ns = d.joinpath("ns_pkg")
ns.mkdir()
ns.joinpath("__init__.py").write_text(
"__import__('pkg_resources').declare_namespace(__name__)"
)
lib = ns.joinpath(dirname)
lib.mkdir()
lib.joinpath("__init__.py").touch()
lib.joinpath(f"test_{dirname}.py").write_text(
f"def test_{dirname}(): pass\ndef test_other():pass"
)
# The structure of the test directory is now:
# .
# ├── hello
# │ └── ns_pkg
# │ ├── __init__.py
# │ └── hello
# │ ├── __init__.py
# │ └── test_hello.py
# └── world
# └── ns_pkg
# ├── __init__.py
# └── world
# ├── __init__.py
# └── test_world.py
# NOTE: the different/reversed ordering is intentional here.
monkeypatch.setenv("PYTHONPATH", prepend_pythonpath(*search_path))
for p in search_path:
monkeypatch.syspath_prepend(p)
# mixed module and filenames:
monkeypatch.chdir("world")
# pgk_resources.declare_namespace has been deprecated in favor of implicit namespace packages.
# While we could change the test to use implicit namespace packages, seems better
# to still ensure the old declaration via declare_namespace still works.
ignore_w = r"-Wignore:Deprecated call to `pkg_resources.declare_namespace"
result = pytester.runpytest(
"--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world", ignore_w
)
assert result.ret == 0
> result.stdout.fnmatch_lines(
[
"test_hello.py::test_hello*PASSED*",
"test_hello.py::test_other*PASSED*",
"ns_pkg/world/test_world.py::test_world*PASSED*",
"ns_pkg/world/test_world.py::test_other*PASSED*",
"*4 passed in*",
]
)
E Failed: nomatch: 'test_hello.py::test_hello*PASSED*'
E and: '============================= test session starts =============================='
E and: 'platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0 -- /usr/bin/python3'
E and: 'cachedir: .pytest_cache'
E and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-8/test_cmdline_python_namespace_package0/world'
E and: 'collecting ... collected 4 items'
E and: ''
E fnmatch: 'test_hello.py::test_hello*PASSED*'
E with: 'test_hello.py::test_hello PASSED [ 25%]'
E fnmatch: 'test_hello.py::test_other*PASSED*'
E with: 'test_hello.py::test_other PASSED [ 50%]'
E fnmatch: 'ns_pkg/world/test_world.py::test_world*PASSED*'
E with: 'ns_pkg/world/test_world.py::test_world PASSED [ 75%]'
E fnmatch: 'ns_pkg/world/test_world.py::test_other*PASSED*'
E with: 'ns_pkg/world/test_world.py::test_other PASSED [100%]'
E nomatch: '*4 passed in*'
E and: ''
E and: '=============================== warnings summary ==============================='
E and: '../../../../../usr/lib/python3.8/site-packages/pkg_resources/__init__.py:121'
E and: ' /usr/lib/python3.8/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API'
E and: ' warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)'
E and: ''
E and: '-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html'
E and: '========================= 4 passed, 1 warning in 0.09s ========================='
E remains unmatched: '*4 passed in*'
/home/tkloczko/rpmbuild/BUILD/pytest-7.3.1/testing/acceptance_test.py:705: Failed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/pytest-of-tkloczko/pytest-8/test_cmdline_python_namespace_package0/world
collecting ... collected 4 items
test_hello.py::test_hello PASSED [ 25%]
test_hello.py::test_other PASSED [ 50%]
ns_pkg/world/test_world.py::test_world PASSED [ 75%]
ns_pkg/world/test_world.py::test_other PASSED [100%]
=============================== warnings summary ===============================
../../../../../usr/lib/python3.8/site-packages/pkg_resources/__init__.py:121
/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================= 4 passed, 1 warning in 0.09s =========================
__________________________________________________________________________ test_raise_assertion_error_raising_repr __________________________________________________________________________
pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-8/test_raise_assertion_error_raising_repr0')>
def test_raise_assertion_error_raising_repr(pytester: Pytester) -> None:
pytester.makepyfile(
"""
class RaisingRepr(object):
def __repr__(self):
raise Exception()
def test_raising_repr():
raise AssertionError(RaisingRepr())
"""
)
result = pytester.runpytest()
> result.stdout.fnmatch_lines(["E AssertionError: <exception str() failed>"])
E Failed: nomatch: 'E AssertionError: <exception str() failed>'
E and: '============================= test session starts =============================='
E and: 'platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0'
E and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-8/test_raise_assertion_error_raising_repr0'
E and: 'collected 1 item'
E and: ''
E and: 'test_raise_assertion_error_raising_repr.py F [100%]'
E and: ''
E and: '=================================== FAILURES ==================================='
E and: '______________________________ test_raising_repr _______________________________'
E and: ''
E and: ' def test_raising_repr():'
E and: '> raise AssertionError(RaisingRepr())'
E and: 'E AssertionError: <unprintable AssertionError object>'
E and: ''
E and: 'test_raise_assertion_error_raising_repr.py:5: AssertionError'
E and: '=========================== short test summary info ============================'
E and: 'FAILED test_raise_assertion_error_raising_repr.py::test_raising_repr - Assert...'
E and: '============================== 1 failed in 0.01s ==============================='
E remains unmatched: 'E AssertionError: <exception str() failed>'
/home/tkloczko/rpmbuild/BUILD/pytest-7.3.1/testing/test_assertion.py:1692: Failed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0
rootdir: /tmp/pytest-of-tkloczko/pytest-8/test_raise_assertion_error_raising_repr0
collected 1 item
test_raise_assertion_error_raising_repr.py F [100%]
=================================== FAILURES ===================================
______________________________ test_raising_repr _______________________________
def test_raising_repr():
> raise AssertionError(RaisingRepr())
E AssertionError: <unprintable AssertionError object>
test_raise_assertion_error_raising_repr.py:5: AssertionError
=========================== short test summary info ============================
FAILED test_raise_assertion_error_raising_repr.py::test_raising_repr - Assert...
============================== 1 failed in 0.01s ===============================
_______________________________________________________________________ test_syspath_prepend_with_namespace_packages ________________________________________________________________________
pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-8/test_syspath_prepend_with_namespace_packages0')>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f68bc77cfd0>
@pytest.mark.filterwarnings(
"ignore:Deprecated call to `pkg_resources.declare_namespace"
)
def test_syspath_prepend_with_namespace_packages(
pytester: Pytester, monkeypatch: MonkeyPatch
) -> None:
for dirname in "hello", "world":
d = pytester.mkdir(dirname)
ns = d.joinpath("ns_pkg")
ns.mkdir()
ns.joinpath("__init__.py").write_text(
"__import__('pkg_resources').declare_namespace(__name__)"
)
lib = ns.joinpath(dirname)
lib.mkdir()
lib.joinpath("__init__.py").write_text("def check(): return %r" % dirname)
monkeypatch.syspath_prepend("hello")
> import ns_pkg.hello
/home/tkloczko/rpmbuild/BUILD/pytest-7.3.1/testing/test_monkeypatch.py:446:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/tmp/pytest-of-tkloczko/pytest-8/test_syspath_prepend_with_namespace_packages0/hello/ns_pkg/__init__.py:1: in <module>
__import__('pkg_resources').declare_namespace(__name__)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
"""
Package resource API
--------------------
A resource is a logical file contained within a package, or a logical
subdirectory thereof. The package resource API expects resource names
to have their path parts separated with ``/``, *not* whatever the local
path separator is. Do not use os.path operations to manipulate resource
names being passed into the API.
The package resource API is designed to work with normal filesystem packages,
.egg files, and unpacked .egg files. It can also work in a limited way with
.zip files and with custom PEP 302 loaders that support the ``get_data()``
method.
This module is deprecated. Users are directed to
`importlib.resources <https://docs.python.org/3/library/importlib.resources.html>`_
and
`importlib.metadata <https://docs.python.org/3/library/importlib.metadata.html>`_
instead.
"""
import sys
import os
import io
import time
import re
import types
import zipfile
import zipimport
import warnings
import stat
import functools
import pkgutil
import operator
import platform
import collections
import plistlib
import email.parser
import errno
import tempfile
import textwrap
import inspect
import ntpath
import posixpath
import importlib
from pkgutil import get_importer
try:
import _imp
except ImportError:
# Python 3.2 compatibility
import imp as _imp
try:
FileExistsError
except NameError:
FileExistsError = OSError
# capture these to bypass sandboxing
from os import utime
try:
from os import mkdir, rename, unlink
WRITE_SUPPORT = True
except ImportError:
# no write support, probably under GAE
WRITE_SUPPORT = False
from os import open as os_open
from os.path import isdir, split
try:
import importlib.machinery as importlib_machinery
# access attribute to force import under delayed import mechanisms.
importlib_machinery.__name__
except ImportError:
importlib_machinery = None
from pkg_resources.extern.jaraco.text import (
yield_lines,
drop_comment,
join_continuation,
)
from pkg_resources.extern import platformdirs
from pkg_resources.extern import packaging
__import__('pkg_resources.extern.packaging.version')
__import__('pkg_resources.extern.packaging.specifiers')
__import__('pkg_resources.extern.packaging.requirements')
__import__('pkg_resources.extern.packaging.markers')
__import__('pkg_resources.extern.packaging.utils')
if sys.version_info < (3, 5):
raise RuntimeError("Python 3.5 or later is required")
# declare some globals that will be defined later to
# satisfy the linters.
require = None
working_set = None
add_activation_listener = None
resources_stream = None
cleanup_resources = None
resource_dir = None
resource_stream = None
set_extraction_path = None
resource_isdir = None
resource_string = None
iter_entry_points = None
resource_listdir = None
resource_filename = None
resource_exists = None
_distribution_finders = None
_namespace_handlers = None
_namespace_packages = None
> warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
E DeprecationWarning: pkg_resources is deprecated as an API
/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:121: DeprecationWarning
================================================================================== short test summary info ==================================================================================
SKIPPED [1] testing/test_capture.py:1446: only on windows
SKIPPED [1] testing/test_findpaths.py:140: condition: sys.platform != 'win32'
SKIPPED [24] testing/test_nose.py:6: could not import 'nose': No module named 'nose'
SKIPPED [1] testing/test_pathlib.py:442: Windows only
SKIPPED [1] testing/test_tmpdir.py:361: win only
SKIPPED [1] testing/_py/test_local.py:449: sys.version_info < (3,6)
SKIPPED [1] testing/_py/test_local.py:454: sys.version_info < (3,6)
SKIPPED [1] testing/_py/test_local.py:650: case insensitive only on windows
SKIPPED [1] testing/_py/test_local.py:868: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1220: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1226: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1238: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1244: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1249: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1257: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1264: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/deprecated_test.py:286: could not import 'nose': No module named 'nose'
SKIPPED [1] testing/deprecated_test.py:315: could not import 'nose': No module named 'nose'
SKIPPED [1] testing/test_assertrewrite.py:770: importlib.resources.files was introduced in 3.9
SKIPPED [1] ../../BUILDROOT/python-pytest-7.3.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/pathlib.py:465: symlinks not supported: [Errno 17] File exists: '/tmp/pytest-of-tkloczko/pytest-8/test_collect_symlink_dir0/symlink_dir' -> '/tmp/pytest-of-tkloczko/pytest-8/test_collect_symlink_dir0/dir'
SKIPPED [1] testing/test_config.py:1860: does not work with xdist currently
SKIPPED [1] testing/test_conftest.py:361: only relevant for case insensitive file systems
SKIPPED [1] testing/test_parseopt.py:330: argcomplete not available
SKIPPED [3] testing/test_warnings.py:521: not relevant until pytest 8.0
SKIPPED [9] testing/code/test_excinfo.py:1563: Native ExceptionGroup not implemented
SKIPPED [41] ../../BUILDROOT/python-pytest-7.3.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/pytester.py:1534: could not import 'pexpect': No module named 'pexpect'
SKIPPED [1] testing/test_faulthandler.py:71: sometimes crashes on CI (#7022)
XFAIL testing/_py/test_local.py::TestLocalPath::test_long_filenames - reason: [NOTRUN] unreliable est for long filenames
XFAIL testing/_py/test_local.py::TestUnicodePy2Py3::test_read_write - changing read/write might break existing usages
XFAIL testing/acceptance_test.py::TestInvocationVariants::test_noclass_discovery_if_not_testcase - decide: feature or bug
XFAIL testing/test_capture.py::TestPerTestCapturing::test_capture_scope_cache - unimplemented feature
XFAIL testing/test_collection.py::TestPrunetraceback::test_collect_report_postprocessing - other mechanism for adding to reporting needed
XFAIL testing/test_config.py::TestParseIni::test_confcutdir - probably not needed
XFAIL testing/test_doctest.py::TestLiterals::test_number_non_matches['3.1416'-'3.14']
XFAIL testing/test_mark.py::TestKeywordSelection::test_keyword_extra_dash
XFAIL testing/test_pytester.py::test_make_hook_recorder - reason: internal reportrecorder tests need refactoring
XFAIL testing/test_runner.py::test_runtest_in_module_ordering
XFAIL testing/python/fixtures.py::TestAutouseDiscovery::test_setup_enabled_functionnode - 'enabled' feature not implemented
XFAIL testing/python/fixtures.py::TestRequestBasic::test_request_garbage - reason: this test is flaky when executed with xdist
FAILED testing/python/raises.py::TestRaises::test_raises_exception_looks_iterable - AssertionError: Regex pattern did not match.
FAILED testing/acceptance_test.py::TestInvocationVariants::test_cmdline_python_namespace_package - Failed: nomatch: 'test_hello.py::test_hello*PASSED*'
FAILED testing/test_assertion.py::test_raise_assertion_error_raising_repr - Failed: nomatch: 'E AssertionError: <exception str() failed>'
FAILED testing/test_monkeypatch.py::test_syspath_prepend_with_namespace_packages - DeprecationWarning: pkg_resources is deprecated as an API
============================================================ 4 failed, 3304 passed, 100 skipped, 12 xfailed in 206.44s (0:03:26) ============================================================ Here is list of installed modules in build env Package Version
------------------------------ -----------------
alabaster 0.7.13
appdirs 1.4.4
asynctest 0.13.0
attrs 22.2.0
Automat 22.10.0
Babel 2.12.1
build 0.10.0
charset-normalizer 3.1.0
constantly 15.1.0
cssselect 1.1.0
decorator 5.1.1
distro 1.8.0
docutils 0.19
elementpath 4.1.1
exceptiongroup 1.0.0
execnet 1.9.0
gpg 1.19.0
hyperlink 21.0.0
hypothesis 6.71.0
idna 3.4
imagesize 1.4.1
importlib-metadata 6.4.1
incremental 22.10.0
iniconfig 2.0.0
installer 0.7.0
Jinja2 3.1.2
libcomps 0.1.19
lxml 4.9.2
MarkupSafe 2.1.2
mock 4.0.3
numpy 1.24.2
olefile 0.46
packaging 23.0
Pallets-Sphinx-Themes 2.0.2
Pillow 9.5.0
pluggy 1.0.0
py 1.11.0
Pygments 2.15.0
pygments-pytest 2.3.0
pyproject_hooks 1.0.0
pytest 7.3.0
pytest-xdist 3.2.0
python-dateutil 2.8.2
pytz 2023.2
requests 2.28.2
scour 0.38.2
setuptools 67.6.1
setuptools-scm 7.1.0
six 1.16.0
snowballstemmer 2.2.0
sortedcontainers 2.4.0
Sphinx 6.1.3
sphinx-removed-in 0.2.1
sphinxcontrib-applehelp 1.0.4
sphinxcontrib-devhelp 1.0.2.dev20230415
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1.dev20230415
sphinxcontrib-qthelp 1.0.3.dev20230415
sphinxcontrib-serializinghtml 1.1.5
sphinxcontrib-svg2pdfconverter 1.2.0
sphinxcontrib-trio 1.1.2
tomli 2.0.1
Twisted 22.10.0
typing_extensions 4.5.0
urllib3 1.26.15
wheel 0.40.0
xmlschema 2.2.3
zipp 3.15.0
zope.event 4.5.0
zope.interface 5.5.2 Definitelly |
Locking this as there clearly seems no intent to fix the broken test setups |
pip list
from the virtual environment you are usingI'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modules-m "not network"
)I see simillar output in #10473
Second failing unit alredy has been reportd in #9764
Here is pytest output:
Here is list of installed modules in build env
The text was updated successfully, but these errors were encountered: