Skip to content
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.1.0: self test is failing in testing/python/raises.py::TestRaises::test_raises_exception_looks_iterable #9764

Closed
4 tasks done
kloczek opened this issue Mar 14, 2022 · 11 comments
Labels
type: selftests a problem in the tests of pytest

Comments

@kloczek
Copy link
Contributor

kloczek commented Mar 14, 2022

  • a detailed description of the bug or problem you are having
    I'm packaging pytest module as the rpm package using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation

  • install .whl file in </install/prefix>

  • run pytest from </install/prefix> with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

  • output of pip list from the virtual environment you are using

Package                       Version
----------------------------- -----------------
alabaster                     0.7.12
argcomplete                   2.0.0
atomicwrites                  1.4.0
attrs                         21.4.0
Automat                       20.2.0
Babel                         2.9.1
build                         0.7.0
charset-normalizer            2.0.12
constantly                    15.1.0
cycler                        0.11.0
decorator                     5.1.1
distro                        1.6.0
docutils                      0.17.1
elementpath                   2.5.0
execnet                       1.9.0
extras                        1.0.0
fixtures                      3.0.0
fonttools                     4.29.0
gpg                           1.17.0-unknown
hyperlink                     21.0.0
hypothesis                    6.39.3
idna                          3.3
imagesize                     1.3.0
importlib-metadata            4.11.2
incremental                   21.3.0
iniconfig                     1.1.1
Jinja2                        3.0.3
kiwisolver                    1.3.2
libcomps                      0.1.18
lit                           13.0.1
MarkupSafe                    2.0.1
matplotlib                    3.5.1
meson                         0.61.2
mock                          4.0.3
more-itertools                8.12.0
numpy                         1.22.3
olefile                       0.46
packaging                     21.3
Pallets-Sphinx-Themes         2.0.2
pbr                           5.8.0
pep517                        0.12.0
pexpect                       4.8.0
Pillow                        9.0.0
pip                           22.0.3
pluggy                        1.0.0
ptyprocess                    0.7.0
py                            1.11.0
Pygments                      2.11.2
pygments-pytest               2.2.0
PyGObject                     3.42.0
pyparsing                     3.0.7
pytest                        6.2.5
pytest-forked                 1.4.0
pytest-timeout                2.1.0
pytest-xdist                  2.5.0
python-dateutil               2.8.2
pytz                          2021.3
requests                      2.27.1
rpm                           4.17.0
setuptools                    60.9.3
setuptools-scm                6.4.2
six                           1.16.0
snowballstemmer               2.2.0
sortedcontainers              2.4.0
Sphinx                        4.4.0.dev20220215
sphinx-removed-in             0.2.1
sphinxcontrib-applehelp       1.0.2.dev20220108
sphinxcontrib-devhelp         1.0.2.dev20220108
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1.dev20220108
sphinxcontrib-qthelp          1.0.3.dev20220108
sphinxcontrib-serializinghtml 1.1.5
sphinxcontrib-trio            1.1.2
testtools                     2.5.0
toml                          0.10.2
tomli                         2.0.1
Twisted                       21.7.0
typing_extensions             4.0.1
urllib3                       1.26.8
wcwidth                       0.2.5
wheel                         0.37.1
xmlschema                     1.10.0
zipp                          3.7.0
zope.event                    4.5.0
zope.interface                5.4.0
  • pytest and operating system versions
    pytest 7.1.0, Linux x85/64, python 3.8.12
  • minimal example if possible
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.1.0-2.fc35.x86_64/usr/bin/pytest -ra --import-mode=importlib -p no:flaky -p no:randomly --timeout=30 testing
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-7.1.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-7.1.0, configfile: pyproject.toml, testpaths: testing
plugins: forked-1.4.0, xdist-2.5.0, timeout-2.1.0, hypothesis-6.39.3
timeout: 30.0s
timeout method: signal
timeout func_only: False
collected 3142 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 ...........                                                                                                                                   [  6%]
testing/test_config.py ....................................................                                                                                          [  7%]
testing/test_conftest.py ...........                                                                                                                                 [  8%]
testing/test_debugging.py .                                                                                                                                          [  8%]
testing/test_doctest.py .............                                                                                                                                [  8%]
testing/test_entry_points.py .                                                                                                                                       [  8%]
testing/test_faulthandler.py ...                                                                                                                                     [  8%]
testing/test_findpaths.py ..............                                                                                                                             [  9%]
testing/test_helpconfig.py .                                                                                                                                         [  9%]
testing/test_junitxml.py ....                                                                                                                                        [  9%]
testing/test_legacypath.py ....                                                                                                                                      [  9%]
testing/test_main.py .....                                                                                                                                           [  9%]
testing/test_mark.py .............                                                                                                                                   [ 10%]
testing/test_mark_expression.py ....................................................................................                                                 [ 12%]
testing/test_monkeypatch.py ...............................                                                                                                          [ 13%]
testing/test_nodes.py ..............                                                                                                                                 [ 14%]
testing/test_nose.py ss                                                                                                                                              [ 14%]
testing/test_parseopt.py ............................                                                                                                                [ 15%]
testing/test_pastebin.py ....                                                                                                                                        [ 15%]
testing/test_pathlib.py .............................................s.....                                                                                          [ 16%]
testing/test_pluginmanager.py .........                                                                                                                              [ 17%]
testing/test_pytester.py .....................                                                                                                                       [ 17%]
testing/test_recwarn.py ........................................                                                                                                     [ 19%]
testing/test_runner.py ..............                                                                                                                                [ 19%]
testing/test_scope.py ....                                                                                                                                           [ 19%]
testing/test_skipping.py .                                                                                                                                           [ 19%]
testing/test_stash.py .                                                                                                                                              [ 19%]
testing/test_terminal.py .......................................                                                                                                     [ 21%]
testing/test_tmpdir.py ...s..............                                                                                                                            [ 21%]
testing/test_warning_types.py ............                                                                                                                           [ 21%]
testing/test_warnings.py .                                                                                                                                           [ 22%]
testing/code/test_code.py .................                                                                                                                          [ 22%]
testing/code/test_excinfo.py ..............................................................................................................................          [ 26%]
testing/code/test_source.py .......................................................                                                                                  [ 28%]
testing/freeze/tests/test_trivial.py ..                                                                                                                              [ 28%]
testing/io/test_saferepr.py ............                                                                                                                             [ 28%]
testing/io/test_terminalwriter.py .............................................                                                                                      [ 30%]
testing/io/test_wcwidth.py .................                                                                                                                         [ 30%]
testing/logging/test_fixture.py ........                                                                                                                             [ 30%]
testing/logging/test_formatter.py ....                                                                                                                               [ 31%]
testing/logging/test_reporting.py ..                                                                                                                                 [ 31%]
testing/python/approx.py .........................................................................                                                                   [ 33%]
testing/python/collect.py ..                                                                                                                                         [ 33%]
testing/python/fixtures.py ..........                                                                                                                                [ 33%]
testing/python/integration.py ....                                                                                                                                   [ 34%]
testing/python/metafunc.py .........................................                                                                                                 [ 35%]
testing/python/raises.py .................F...                                                                                                                       [ 35%]
testing/freeze/tests/test_doctest.txt .                                                                                                                              [ 36%]
testing/acceptance_test.py ..................................................x...................                                                                    [ 38%]
testing/deprecated_test.py ...........                                                                                                                               [ 38%]
testing/test_assertion.py ..................................                                                                                                         [ 39%]
testing/test_assertrewrite.py .............s...............................                                                                                          [ 41%]
testing/test_cacheprovider.py ...................................................                                                                                    [ 42%]
testing/test_capture.py ......x....................................                                                                                                  [ 44%]
testing/test_collection.py ...........................x.....................................s.................                                                       [ 46%]
testing/test_compat.py ..                                                                                                                                            [ 46%]
testing/test_config.py ............x..............................................................................s.................................                 [ 50%]
testing/test_conftest.py ............s.............................                                                                                                  [ 52%]
testing/test_debugging.py ............                                                                                                                               [ 52%]
testing/test_doctest.py .............................................................x..........................................................                     [ 56%]
testing/test_error_diffs.py ............                                                                                                                             [ 56%]
testing/test_faulthandler.py ...                                                                                                                                     [ 56%]
testing/test_helpconfig.py ........                                                                                                                                  [ 57%]
testing/test_junitxml.py ............................................................................................................................                [ 61%]
testing/test_legacypath.py ..........                                                                                                                                [ 61%]
testing/test_link_resolve.py .                                                                                                                                       [ 61%]
testing/test_main.py .............                                                                                                                                   [ 61%]
testing/test_mark.py ...........................................................x................                                                                    [ 64%]
testing/test_monkeypatch.py ....                                                                                                                                     [ 64%]
testing/test_nodes.py ....                                                                                                                                           [ 64%]
testing/test_nose.py ssssssssssssssssssss                                                                                                                            [ 65%]
testing/test_parseopt.py .                                                                                                                                           [ 65%]
testing/test_pastebin.py ...                                                                                                                                         [ 65%]
testing/test_pluginmanager.py ................                                                                                                                       [ 65%]
testing/test_pytester.py x.........................                                                                                                                  [ 66%]
testing/test_python_path.py .....                                                                                                                                    [ 66%]
testing/test_recwarn.py ..                                                                                                                                           [ 66%]
testing/test_reports.py .................                                                                                                                            [ 67%]
testing/test_runner.py ......................x.....................                                                                                                  [ 68%]
testing/test_runner_xunit.py .............                                                                                                                           [ 69%]
testing/test_session.py ........................                                                                                                                     [ 69%]
testing/test_setuponly.py ..........................                                                                                                                 [ 70%]
testing/test_setupplan.py ...                                                                                                                                        [ 70%]
testing/test_skipping.py ...........................................................................................                                                 [ 73%]
testing/test_stepwise.py ............                                                                                                                                [ 74%]
testing/test_terminal.py ................................................................................................................                            [ 77%]
testing/test_threadexception.py ....                                                                                                                                 [ 77%]
testing/test_tmpdir.py ................                                                                                                                              [ 78%]
testing/test_unittest.py ............................................................s........                                                                       [ 80%]
testing/test_unraisableexception.py ....                                                                                                                             [ 80%]
testing/test_warning_types.py .                                                                                                                                      [ 80%]
testing/test_warnings.py ...................sss.........                                                                                                             [ 81%]
testing/code/test_excinfo.py ....                                                                                                                                    [ 81%]
testing/examples/test_issue519.py .                                                                                                                                  [ 81%]
testing/logging/test_fixture.py .......                                                                                                                              [ 82%]
testing/logging/test_reporting.py ......................................                                                                                             [ 83%]
testing/python/approx.py .                                                                                                                                           [ 83%]
testing/python/collect.py ...........................................................................                                                                [ 85%]
testing/python/fixtures.py .......................................................................x................................................................. [ 90%]
....................................                                                                                                                                 [ 91%]
testing/python/integration.py ...............                                                                                                                        [ 91%]
testing/python/metafunc.py ............................................................                                                                              [ 93%]
testing/python/raises.py ...                                                                                                                                         [ 93%]
testing/python/show_fixtures_per_test.py ........                                                                                                                    [ 93%]
testing/acceptance_test.py ....                                                                                                                                      [ 94%]
testing/test_assertion.py ............                                                                                                                               [ 94%]
testing/test_assertrewrite.py .........                                                                                                                              [ 94%]
testing/test_capture.py ........................                                                                                                                     [ 95%]
testing/test_collection.py .                                                                                                                                         [ 95%]
testing/test_compat.py .                                                                                                                                             [ 95%]
testing/test_config.py ..                                                                                                                                            [ 95%]
testing/test_debugging.py ............................................                                                                                               [ 96%]
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 .....                                                                                                                                       [ 99%]
testing/test_reports.py .                                                                                                                                            [ 99%]
testing/test_terminal.py ....                                                                                                                                        [ 99%]
testing/test_unittest.py ..                                                                                                                                          [ 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 0x7f5a54fbc550>

    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)

testing/python/raises.py:259:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

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 0x7f5a53e36310>,), kwargs = {}, __tracebackhide__ = True
excepted_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 0x7f5a53e36310>

    def raises(
        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 ``expected_exception``
        or raise a failure exception otherwise.

        :kwparam 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 :py:func:`re.search`. To match a literal
            string that may contain :std:ref:`special characters <re-syntax>`, the pattern can
            first be escaped with :py: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 isinstance(expected_exception, type):
            excepted_exceptions: Tuple[Type[E], ...] = (expected_exception,)
        else:
            excepted_exceptions = expected_exception
        for exc in excepted_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)

../../BUILDROOT/python-pytest-7.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/python_api.py:935:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

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'>

../../BUILDROOT/python-pytest-7.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/outcomes.py:196: Failed

During handling of the above exception, another exception occurred:

self = <testing.python.raises.TestRaises object at 0x7f5a54fbc550>

    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 RAISE <class 'raises(\\..*)*ClassLooksIterableException'>" does not match "DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>".

testing/python/raises.py:259: AssertionError
========================================================================= short test summary info ==========================================================================
SKIPPED [1] testing/test_capture.py:1432: only on windows
SKIPPED [22] testing/test_nose.py:6: could not import 'nose': No module named 'nose'
SKIPPED [1] testing/test_pathlib.py:436: Windows only
SKIPPED [1] testing/test_tmpdir.py:221: win only
SKIPPED [1] testing/test_assertrewrite.py:800: importlib.resources.files was introduced in 3.9
SKIPPED [1] ../../BUILDROOT/python-pytest-7.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/pathlib.py:434: symlinks not supported: [Errno 17] File exists: '/tmp/pytest-of-tkloczko/pytest-21/test_collect_symlink_dir0/symlink_dir' -> '/tmp/pytest-of-tkloczko/pytest-21/test_collect_symlink_dir0/dir'
SKIPPED [1] testing/test_config.py:1849: does not work with xdist currently
SKIPPED [1] testing/test_conftest.py:333: only relevant for case insensitive file systems
SKIPPED [1] testing/test_unittest.py:1287: could not import 'asynctest': No module named 'asynctest'
SKIPPED [3] testing/test_warnings.py:521: not relevant until pytest 8.0
SKIPPED [1] testing/test_faulthandler.py:71: sometimes crashes on CI (#7022)
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 RAISE <class 'raises(\\..*)*ClassLooksIterable...
==================================================== 1 failed, 3097 passed, 34 skipped, 10 xfailed in 207.27s (0:03:27) ====================================================
@Zac-HD Zac-HD added the type: selftests a problem in the tests of pytest label Mar 15, 2022
@kloczek
Copy link
Contributor Author

kloczek commented Apr 23, 2022

BTW ..

SKIPPED [22] testing/test_nose.py:6: could not import 'nose': No module named 'nose'

I think that this can be now removed as nose is only for python 2.x.

@The-Compiler
Copy link
Member

@kloczek I've corrected you on this before, but I'll happily do it again: nose is old, but it runs on Python 3 just fine. It's even mentioned right on their homepage. I have no idea where you're getting this from.

@kloczek
Copy link
Contributor Author

kloczek commented Apr 23, 2022

Issue is that nose depends on few modules which are not in-so-good-condition in context of python 3.x😋

@The-Compiler
Copy link
Member

It breaks on Python 3.10 due to the collections.abc move (how that is a "few modules" and "which are not in-so-good-condition" is beyond me). It works just fine on three other still supported versions of Python 3. So, I'm afraid I still have no idea what you're talking about.

@kloczek
Copy link
Contributor Author

kloczek commented Apr 23, 2022

IIRC nose-case and some related .. I don't remeber now exact details as more than year ago I made decision to get rid of nose from set of rpm packages with python modules which I'm mantaining (ATM it is +900 such packages). I've helped as well in case ~10 modules move to pytest using nose2pytest.
Currently still have 20 modules with opened some issue tickets about move away from nose. As I have those usnits which are still using nose in pytest --deselect list helping maintainers remove nose is not on my high priority list.
Nevertheless .. nose is dead 😄

[tkloczko@devel-g2v SPECS]$ grep "BUG.*nose" python-*
python-beaker.spec:# BUG: pytest is using outdated nose module https://github.com/bbangert/beaker/issues/218
python-billiard.spec:# BUG: uses nose https://github.com/celery/billiard/issues/337
python-blessings.spec:# BUG: uses nose https://github.com/erikrose/blessings/issues/164
python-boto.spec:# BUG: test suite is using nose https://github.com/boto/boto/issues/3932
python-colorspacious.spec:# BUG: test suite is using nose
python-cycler.spec:# BUG: replace nose by ptest https://github.com/matplotlib/cycler/issues/73
python-flaky.spec:# BUG: test suite uses outdated nose module https://github.com/box/flaky/issues/180
python-gitdb.spec:# BUG: test suite uses nose https://github.com/gitpython-developers/gitdb/issues/72
python-httpretty.spec:# BUG: still has some nose dependencies https://github.com/gabrielfalcao/HTTPretty/issues/439
python-ipython_genutils.spec:# BUG: pytest test suite is failing and is using nose https://github.com/ipython/ipython_genutils/issues/18
python-ipython.spec:# BUG: pytest warnings and test suite is using nose https://github.com/ipython/ipython/issues/13018
python-jsondiff.spec:# BUG: test suite is using nose-randomly https://github.com/xlwings/jsondiff/issues/44
python-parameterized.spec:# BUG: test suite is using nose https://github.com/wolever/parameterized/issues/122
python-pylibmc.spec:# BUG: test suite uses nose https://github.com/lericson/pylibmc/issues/275
python-pyutilib.spec:# BUG: test suite uses nose https://github.com/PyUtilib/pyutilib/issues/116
python-rdflib-sqlalchemy.spec:# BUG: test suite uses nose https://github.com/RDFLib/rdflib-sqlalchemy/issues/90
python-sure.spec:# BUG: test suite iuses nose https://github.com/gabrielfalcao/sure/issues/182
python-traittypes.spec:# BUG: test suite is using nose https://github.com/jupyter-widgets/traittypes/issues/46
python-vine.spec:# BUG: test suite uses case module which uses nose which is deprecated https://github.com/celery/vine/issues/61
python-zerorpc.spec:# BUG: test suite is using nose https://github.com/0rpc/zerorpc-python/issues/243
[tkloczko@devel-g2v SPECS]$ grep "BUG.*nose" python-* |wc -l
20

@kloczek
Copy link
Contributor Author

kloczek commented Sep 2, 2022

Just retested 7.1.3 and sttill I see failing testing/python/raises.py::TestRaises::test_raises_exception_looks_iterable unit.
Is it anything what I can try to do to help diagnose that units? 🤔

@kloczek
Copy link
Contributor Author

kloczek commented Sep 7, 2023

Just FTR still see in just released 7.2.2 testing/python/raises.py::TestRaises::test_raises_exception_looks_iterable failing

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.4.2-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /home/tkloczko/rpmbuild/BUILDROOT/python-pytest-7.4.2-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.18, pytest-7.4.2, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-7.4.2
configfile: pyproject.toml
testpaths: testing
plugins: xdist-3.3.1, hypothesis-6.82.0
collected 3465 items

testing/acceptance_test.py .....                                         [  0%]
testing/deprecated_test.py .......                                       [  0%]
testing/test_argcomplete.py ..                                           [  0%]
testing/test_assertion.py .............................................. [  1%]
.......................                                                  [  2%]
testing/test_assertrewrite.py .......................................... [  3%]
..                                                                       [  3%]
testing/test_capture.py ................................................ [  5%]
........s....s..                                                         [  5%]
testing/test_collection.py .                                             [  5%]
testing/test_compat.py ...........                                       [  5%]
testing/test_config.py ................................................. [  7%]
.....                                                                    [  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 ....                                            [  8%]
testing/test_legacypath.py ....                                          [  9%]
testing/test_main.py .....                                               [  9%]
testing/test_mark.py ..............                                      [  9%]
testing/test_mark_expression.py ........................................ [ 10%]
............................................                             [ 12%]
testing/test_monkeypatch.py ...............................              [ 12%]
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%]
......                                                                   [ 15%]
testing/test_pluginmanager.py .........                                  [ 16%]
testing/test_pytester.py .....................                           [ 16%]
testing/test_recwarn.py ........................................         [ 17%]
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 .............................................. [ 21%]
...................ss..............s.................x......s........... [ 23%]
..........................sssssss............................x...        [ 25%]
testing/code/test_code.py .................                              [ 26%]
testing/code/test_excinfo.py ........................................... [ 27%]
........................................................................ [ 29%]
..............                                                           [ 30%]
testing/code/test_source.py ............................................ [ 31%]
...........                                                              [ 31%]
testing/freeze/tests/test_trivial.py ..                                  [ 31%]
testing/io/test_saferepr.py ..............                               [ 32%]
testing/io/test_terminalwriter.py ...................................... [ 33%]
.......                                                                  [ 33%]
testing/io/test_wcwidth.py .................                             [ 33%]
testing/logging/test_fixture.py ..................                       [ 34%]
testing/logging/test_formatter.py ....                                   [ 34%]
testing/logging/test_reporting.py ..                                     [ 34%]
testing/python/approx.py ............................................... [ 35%]
..................................                                       [ 36%]
testing/python/collect.py ..                                             [ 36%]
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 ............................................. [ 40%]
.....x....................                                               [ 41%]
testing/deprecated_test.py ...........ss                                 [ 41%]
testing/test_assertion.py ...................................            [ 42%]
testing/test_assertrewrite.py .............s............................ [ 43%]
....................                                                     [ 44%]
testing/test_cacheprovider.py .......................................... [ 45%]
.............                                                            [ 46%]
testing/test_capture.py ......x........................s...........      [ 47%]
testing/test_collection.py ...........................x................. [ 48%]
.......................s.................                                [ 49%]
testing/test_compat.py ..                                                [ 49%]
testing/test_config.py ...............x................................. [ 51%]
.............................................s.......................... [ 53%]
.......                                                                  [ 53%]
testing/test_conftest.py .............s.............................     [ 54%]
testing/test_debugging.py .............                                  [ 55%]
testing/test_doctest.py ................................................ [ 56%]
...............x........................................................ [ 58%]
..                                                                       [ 58%]
testing/test_error_diffs.py ............                                 [ 59%]
testing/test_faulthandler.py ...                                         [ 59%]
testing/test_helpconfig.py ........                                      [ 59%]
testing/test_junitxml.py ............................................... [ 60%]
........................................................................ [ 62%]
.......                                                                  [ 62%]
testing/test_legacypath.py ..........                                    [ 63%]
testing/test_link_resolve.py .                                           [ 63%]
testing/test_main.py ..............                                      [ 63%]
testing/test_mark.py ................................................... [ 65%]
........x................                                                [ 65%]
testing/test_monkeypatch.py ....                                         [ 66%]
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 ............................................... [ 73%]
.............................................                            [ 74%]
testing/test_stepwise.py ..............                                  [ 75%]
testing/test_terminal.py ............................................... [ 76%]
.......................................................................  [ 78%]
testing/test_threadexception.py ....                                     [ 78%]
testing/test_tmpdir.py ....................                              [ 79%]
testing/test_unittest.py ............................................... [ 80%]
........................                                                 [ 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%]
.......                                                                  [ 84%]
testing/python/approx.py .                                               [ 84%]
testing/python/collect.py .............................................. [ 86%]
.............................                                            [ 86%]
testing/python/fixtures.py ............................................. [ 88%]
..........................x............................................. [ 90%]
.........................................................                [ 91%]
testing/python/integration.py ...............                            [ 92%]
testing/python/metafunc.py ............................................. [ 93%]
...............                                                          [ 94%]
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 ................................................... [ 98%]
................                                                         [ 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 0x7f78395f5a60>

    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           Failed: DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>

/home/tkloczko/rpmbuild/BUILD/pytest-7.4.2/testing/python/raises.py:264: Failed

During handling of the above exception, another exception occurred:

self = <testing.python.raises.TestRaises object at 0x7f78395f5a60>

    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.4.2/testing/python/raises.py:264: AssertionError
=========================== short test summary info ============================
SKIPPED [2] testing/test_capture.py:961: could not run 'lsof' (FileNotFoundError(2, 'No such file or directory'))
SKIPPED [1] testing/test_capture.py:1447: 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:458: Windows only
SKIPPED [1] testing/test_tmpdir.py:361: win only
SKIPPED [1] testing/_py/test_local.py:462: sys.version_info < (3,6)
SKIPPED [1] testing/_py/test_local.py:467: sys.version_info < (3,6)
SKIPPED [1] testing/_py/test_local.py:667: case insensitive only on windows
SKIPPED [1] testing/_py/test_local.py:885: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1237: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1243: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1255: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1261: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1266: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1274: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1281: 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:773: importlib.resources.files was introduced in 3.9
SKIPPED [1] ../../BUILDROOT/python-pytest-7.4.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/pathlib.py:466: symlinks not supported: [Errno 17] File exists: '/tmp/pytest-of-tkloczko/pytest-25/test_collect_symlink_dir0/symlink_dir' -> '/tmp/pytest-of-tkloczko/pytest-25/test_collect_symlink_dir0/dir'
SKIPPED [1] testing/test_config.py:1894: does not work with xdist currently
SKIPPED [1] testing/test_conftest.py:374: only relevant for case insensitive file systems
SKIPPED [1] testing/test_parseopt.py:336: argcomplete not available
SKIPPED [3] testing/test_warnings.py:521: not relevant until pytest 8.0
SKIPPED [9] testing/code/test_excinfo.py:1573: Native ExceptionGroup not implemented
SKIPPED [41] ../../BUILDROOT/python-pytest-7.4.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/_pytest/pytester.py:1536: 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
===== 1 failed, 3350 passed, 102 skipped, 12 xfailed in 207.38s (0:03:27) ======

@RonnyPfannschmidt
Copy link
Member

Closing as not planned

@RonnyPfannschmidt RonnyPfannschmidt closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2023
@kloczek
Copy link
Contributor Author

kloczek commented Sep 7, 2023

Hmm what in this case means "not planned"? 🤔

@RonnyPfannschmidt
Copy link
Member

Based on the surrounding issues and prior issues, this is a artifact of how your particular packaging pipeline works

@kloczek
Copy link
Contributor Author

kloczek commented Sep 8, 2023

Based on the surrounding issues and prior issues, this is a artifact of how your particular packaging pipeline works

So it "cannot be reproduced" and has nothing to do with "not planned" 🤔
Right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: selftests a problem in the tests of pytest
Projects
None yet
Development

No branches or pull requests

4 participants