Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1892612 - pytest fails to build with Python 3.10: AssertionError: assert '' == '{{ h()}}:' + timeout
Summary: pytest fails to build with Python 3.10: AssertionError: assert '' == '{{ h()}...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: pytest
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1914843
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2020-10-29 10:28 UTC by Tomáš Hrnčiar
Modified: 2021-02-18 23:04 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-02-18 23:04:36 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2020-10-29 10:28:45 UTC
pytest fails to build with Python 3.10.0a1.

=================================== FAILURES ===================================
_____________ TestExecutionNonForked.test_exact_teardown_issue1206 _____________

self = <test_runner.TestExecutionNonForked object at 0x7f12f023b760>
testdir = <Testdir local('/tmp/pytest-of-mockbuild/pytest-0/test_exact_teardown_issue12060')>

    def test_exact_teardown_issue1206(self, testdir) -> None:
        """issue shadowing error with wrong number of arguments on teardown_method."""
        rec = testdir.inline_runsource(
            """
            import pytest
    
            class TestClass(object):
                def teardown_method(self, x, y, z):
                    pass
    
                def test_method(self):
                    assert True
        """
        )
        reps = rec.getreports("pytest_runtest_logreport")
        print(reps)
        assert len(reps) == 3
        #
        assert reps[0].nodeid.endswith("test_method")
        assert reps[0].passed
        assert reps[0].when == "setup"
        #
        assert reps[1].nodeid.endswith("test_method")
        assert reps[1].passed
        assert reps[1].when == "call"
        #
        assert reps[2].nodeid.endswith("test_method")
        assert reps[2].failed
        assert reps[2].when == "teardown"
>       assert reps[2].longrepr.reprcrash.message in (
            # python3 error
            "TypeError: teardown_method() missing 2 required positional arguments: 'y' and 'z'",
            # python2 error
            "TypeError: teardown_method() takes exactly 4 arguments (2 given)",
        )
E       assert "TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'" in ("TypeError: teardown_method() missing 2 required positional arguments: 'y' and 'z'", 'TypeError: teardown_method() takes exactly 4 arguments (2 given)')
E        +  where "TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'" = ReprFileLocation(path='/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/p...py', lineno=674, message="TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'").message
E        +    where ReprFileLocation(path='/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/p...py', lineno=674, message="TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'") = ExceptionChainRepr(chain=[(ReprTraceback(reprentries=[ReprEntry(lines=['    @classmethod', '    def from_call(', '    ...no=674, message="TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'"), None)]).reprcrash
E        +      where ExceptionChainRepr(chain=[(ReprTraceback(reprentries=[ReprEntry(lines=['    @classmethod', '    def from_call(', '    ...no=674, message="TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'"), None)]) = <TestReport 'test_exact_teardown_issue1206.py::TestClass::test_method' when='teardown' outcome='failed'>.longrepr

/builddir/build/BUILD/pytest-6.0.2/testing/test_runner.py:341: AssertionError
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.0a1, pytest-6.0.2, py-1.9.0, pluggy-0.13.1
rootdir: /tmp/pytest-of-mockbuild/pytest-0/test_exact_teardown_issue12060
collected 1 item

test_exact_teardown_issue1206.py .E                                      [100%]

==================================== ERRORS ====================================
__________________ ERROR at teardown of TestClass.test_method __________________

cls = <class '_pytest.runner.CallInfo'>
func = <function call_runtest_hook.<locals>.<lambda> at 0x7f12f0205dc0>
when = 'teardown'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: "Callable[[], _T]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: "Optional[Union[Type[BaseException], Tuple[Type[BaseException], ...]]]" = None,
    ) -> "CallInfo[_T]":
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result = func()  # type: Optional[_T]

/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:294: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:247: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
/usr/lib/python3.10/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3.10/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.10/site-packages/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
/usr/lib/python3.10/site-packages/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
/usr/lib/python3.10/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:166: in pytest_runtest_teardown
    item.session._setupstate.teardown_exact(item, nextitem)
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:402: in teardown_exact
    self._teardown_towards(needed_collectors)
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:417: in _teardown_towards
    raise exc
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:410: in _teardown_towards
    self._pop_and_teardown()
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:370: in _pop_and_teardown
    self._teardown_with_finalization(colitem)
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:388: in _teardown_with_finalization
    self._callfinalizers(colitem)
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:385: in _callfinalizers
    raise exc
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:378: in _callfinalizers
    fin()
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/fixtures.py:1023: in finish
    raise exc
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/fixtures.py:1016: in finish
    func()
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/fixtures.py:932: in _teardown_yield_fixture
    next(it)
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/python.py:774: in xunit_setup_method_fixture
    _call_with_optional_argument(func, method)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

func = <bound method TestClass.teardown_method of <test_exact_teardown_issue1206.TestClass object at 0x7f12f02271f0>>
arg = <bound method TestClass.test_method of <test_exact_teardown_issue1206.TestClass object at 0x7f12f02271f0>>

    def _call_with_optional_argument(func, arg) -> None:
        """Call the given function with the given argument if func accepts one argument, otherwise
        calls func without arguments"""
        arg_count = func.__code__.co_argcount
        if inspect.ismethod(func):
            arg_count -= 1
        if arg_count:
>           func(arg)
E           TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'

/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/python.py:674: TypeError
=========================== short test summary info ============================
ERROR test_exact_teardown_issue1206.py::TestClass::test_method - TypeError: T...
========================== 1 passed, 1 error in 0.15s ==========================
[<TestReport 'test_exact_teardown_issue1206.py::TestClass::test_method' when='setup' outcome='passed'>, <TestReport 'test_exact_teardown_issue1206.py::TestClass::test_method' when='call' outcome='passed'>, <TestReport 'test_exact_teardown_issue1206.py::TestClass::test_method' when='teardown' outcome='failed'>]
=============================== warnings summary ===============================
testing/acceptance_test.py: 2 warnings
testing/deprecated_test.py: 1 warning
testing/test_assertion.py: 2 warnings
testing/test_cacheprovider.py: 1 warning
testing/test_junitxml.py: 3 warnings
testing/test_pluginmanager.py: 1 warning
testing/test_terminal.py: 3 warnings
testing/test_warnings.py: 11 warnings
testing/python/collect.py: 2 warnings
  /builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/compat.py:340: PytestDeprecationWarning: The TerminalReporter.writer attribute is deprecated, use TerminalReporter._tw instead at your own risk.
  See https://docs.pytest.org/en/stable/deprecations.html#terminalreporter-writer for more information.
    return getattr(object, name, default)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED testing/test_runner.py::TestExecutionNonForked::test_exact_teardown_issue1206
= 1 failed, 2952 passed, 26 skipped, 9 xfailed, 26 warnings in 183.69s (0:03:03) =
error: Bad exit status from /var/tmp/rpm-tmp.JLvmkv (%check)
    bogus date in %changelog: Mon Jul 28 2020 Miro HronÄok <mhroncok> - 6.0.0~rc1-1
    Bad exit status from /var/tmp/rpm-tmp.JLvmkv (%check)

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01726314-pytest/

For all our attempts to build pytest with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/pytest/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2020-10-29 10:34:00 UTC
Seems like a exception message difference only. Might be fixed upstream in newer versions, I will check/report/fix.

Comment 2 Miro Hrončok 2020-10-29 10:38:36 UTC
Seems to be fixed in https://github.com/pytest-dev/pytest/commit/d9ac2efbcdee123f73edf1829c8bd6a91be3b6d2 (not yet released)

Comment 3 Miro Hrončok 2020-11-20 08:34:24 UTC
Backporting the patch, also to pytest4.

Comment 4 Miro Hrončok 2020-11-20 08:45:31 UTC
Fedora backport for pytest 6: https://src.fedoraproject.org/rpms/pytest/pull-request/18

Upstream backport for pytest 4: https://github.com/pytest-dev/pytest/pull/8054

Fedora backport for pytest 4: https://src.fedoraproject.org/rpms/python-pytest4/pull-request/2

Comment 5 Miro Hrončok 2020-12-19 18:47:07 UTC
There is a new failure now:

=================================== FAILURES ===================================
_____________________________ test_syspath_prepend _____________________________

mp = <_pytest.monkeypatch.MonkeyPatch object at 0x7f2164af4bb0>

    def test_syspath_prepend(mp: MonkeyPatch) -> None:
        old = list(sys.path)
>       mp.syspath_prepend("world")

testing/test_monkeypatch.py:252: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/monkeypatch.py:300: in syspath_prepend
    from pkg_resources import fixup_namespace_packages
/usr/lib/python3.10/site-packages/pkg_resources/__init__.py:73: in <module>
    from pkg_resources.extern import appdirs
<frozen importlib._bootstrap>:1026: in _find_and_load
    ???
<frozen importlib._bootstrap>:1005: in _find_and_load_unlocked
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

spec = ModuleSpec(name='pkg_resources.extern.appdirs', loader=<pkg_resources.extern.VendorImporter object at 0x7f2164a68d60>)

>   ???
E   ImportWarning: VendorImporter.exec_module() not found; falling back to load_module()

<frozen importlib._bootstrap>:681: ImportWarning
_______________________ test_syspath_prepend_double_undo _______________________

mp = <_pytest.monkeypatch.MonkeyPatch object at 0x7f2164a31040>

    def test_syspath_prepend_double_undo(mp: MonkeyPatch) -> None:
        old_syspath = sys.path[:]
        try:
>           mp.syspath_prepend("hello world")

testing/test_monkeypatch.py:265: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/monkeypatch.py:300: in syspath_prepend
    from pkg_resources import fixup_namespace_packages
/usr/lib/python3.10/site-packages/pkg_resources/__init__.py:73: in <module>
    from pkg_resources.extern import appdirs
<frozen importlib._bootstrap>:1026: in _find_and_load
    ???
<frozen importlib._bootstrap>:1005: in _find_and_load_unlocked
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

spec = ModuleSpec(name='pkg_resources.extern.appdirs', loader=<pkg_resources.extern.VendorImporter object at 0x7f2164a68d60>)

>   ???
E   ImportWarning: VendorImporter.exec_module() not found; falling back to load_module()

<frozen importlib._bootstrap>:681: ImportWarning
______________________ test_excinfo_no_python_sourcecode _______________________

tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_excinfo_no_python_sourcec0')

    def test_excinfo_no_python_sourcecode(tmpdir):
        # XXX: simplified locally testable version
        tmpdir.join("test.txt").write("{{ h()}}:")
    
        jinja2 = pytest.importorskip("jinja2")
        loader = jinja2.FileSystemLoader(str(tmpdir))
        env = jinja2.Environment(loader=loader)
        template = env.get_template("test.txt")
        excinfo = pytest.raises(ValueError, template.render, h=h)
        for item in excinfo.traceback:
            print(item)  # XXX: for some reason jinja.Template.render is printed in full
            item.source  # shouldn't fail
            if isinstance(item.path, py.path.local) and item.path.basename == "test.txt":
>               assert str(item.source) == "{{ h()}}:"
E               AssertionError: assert '' == '{{ h()}}:'
E                 - {{ h()}}:

testing/code/test_excinfo.py:382: AssertionError
----------------------------- Captured stdout call -----------------------------
  File '/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/python_api.py':706 in raises
  func(*args[1:], **kwargs)

  File '/usr/lib/python3.10/site-packages/jinja2/environment.py':1090 in render
  self.environment.handle_exception()

  File '/usr/lib/python3.10/site-packages/jinja2/environment.py':832 in handle_exception
  reraise(*rewrite_traceback_stack(source=source))

  File '/usr/lib/python3.10/site-packages/jinja2/_compat.py':28 in reraise
  raise value.with_traceback(tb)

  File '/tmp/pytest-of-mockbuild/pytest-0/test_excinfo_no_python_sourcec0/test.txt':-4 in top-level template code
  ???

_________ TestInvocationVariants.test_cmdline_python_namespace_package _________

self = <acceptance_test.TestInvocationVariants object at 0x7f214e9e9850>
testdir = <Testdir local('/tmp/pytest-of-mockbuild/pytest-0/test_cmdline_python_namespace_package0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f214ea007f0>

    def test_cmdline_python_namespace_package(self, testdir, monkeypatch):
        """
        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 = testdir.mkdir(dirname)
            search_path.append(d)
            ns = d.mkdir("ns_pkg")
            ns.join("__init__.py").write(
                "__import__('pkg_resources').declare_namespace(__name__)"
            )
            lib = ns.mkdir(dirname)
            lib.ensure("__init__.py")
            lib.join("test_{}.py".format(dirname)).write(
                "def test_{}(): pass\ndef test_other():pass".format(dirname)
            )
    
        # 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")
        result = testdir.runpytest("--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world")
        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.10.0a3, pytest-6.0.2, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python3'
E           and: 'cachedir: .pytest_cache'
E           and: 'rootdir: /tmp/pytest-of-mockbuild/pytest-0/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: '<frozen importlib._bootstrap>:283'
E           and: '  <frozen importlib._bootstrap>:283: DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead'
E           and: ''
E           and: '-- Docs: https://docs.pytest.org/en/stable/warnings.html'
E           and: '========================= 4 passed, 1 warning in 0.02s ========================='
E       remains unmatched: '*4 passed in*'

/builddir/build/BUILD/pytest-6.0.2/testing/acceptance_test.py:712: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.0a3, pytest-6.0.2, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/pytest-of-mockbuild/pytest-0/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 ===============================
<frozen importlib._bootstrap>:283
  <frozen importlib._bootstrap>:283: DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================= 4 passed, 1 warning in 0.02s =========================
_________________ test_syspath_prepend_with_namespace_packages _________________

testdir = <Testdir local('/tmp/pytest-of-mockbuild/pytest-0/test_syspath_prepend_with_namespace_packages0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f212eded160>

    def test_syspath_prepend_with_namespace_packages(
        testdir: Testdir, monkeypatch: MonkeyPatch
    ) -> None:
        for dirname in "hello", "world":
            d = testdir.mkdir(dirname)
            ns = d.mkdir("ns_pkg")
            ns.join("__init__.py").write(
                "__import__('pkg_resources').declare_namespace(__name__)"
            )
            lib = ns.mkdir(dirname)
            lib.join("__init__.py").write("def check(): return %r" % dirname)
    
>       monkeypatch.syspath_prepend("hello")

/builddir/build/BUILD/pytest-6.0.2/testing/test_monkeypatch.py:427: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILDROOT/pytest-6.0.2-1.fc34.x86_64/usr/lib/python3.10/site-packages/_pytest/monkeypatch.py:307: in syspath_prepend
    fixup_namespace_packages(str(path))
/usr/lib/python3.10/site-packages/pkg_resources/__init__.py:2290: in fixup_namespace_packages
    subpath = _handle_ns(package, path_item)
/usr/lib/python3.10/site-packages/pkg_resources/__init__.py:2212: in _handle_ns
    loader.load_module(packageName)
<frozen importlib._bootstrap_external>:508: in _check_name_wrapper
    ???
<frozen importlib._bootstrap_external>:1012: in load_module
    ???
<frozen importlib._bootstrap_external>:837: in load_module
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_frozen_importlib_external.SourceFileLoader object at 0x7f212eded400>
fullname = 'ns_pkg'

>   ???
E   DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead

<frozen importlib._bootstrap>:283: DeprecationWarning
_________________ TestPDB.test_pdb_interaction_capturing_twice _________________

self = <test_debugging.TestPDB object at 0x7f2119db88e0>
testdir = <Testdir local('/tmp/pytest-of-mockbuild/pytest-0/test_pdb_interaction_capturing_twice0')>

    def test_pdb_interaction_capturing_twice(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            def test_1():
                i = 0
                print("hello17")
                pytest.set_trace()
                x = 3
                print("hello18")
                pytest.set_trace()
                x = 4
                assert 0
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect(r"PDB set_trace \(IO-capturing turned off\)")
        child.expect("test_1")
        child.expect("x = 3")
        child.expect("Pdb")
        child.sendline("c")
        child.expect(r"PDB continue \(IO-capturing resumed\)")
        child.expect(r"PDB set_trace \(IO-capturing turned off\)")
>       child.expect("x = 4")

/builddir/build/BUILD/pytest-6.0.2/testing/test_debugging.py:545: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/site-packages/pexpect/spawnbase.py:343: in expect
    return self.expect_list(compiled_pattern_list,
/usr/lib/python3.10/site-packages/pexpect/spawnbase.py:372: in expect_list
    return exp.expect_loop(timeout)
/usr/lib/python3.10/site-packages/pexpect/expect.py:181: in expect_loop
    return self.timeout(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pexpect.expect.Expecter object at 0x7f211a09f0d0>
err = TIMEOUT('Timeout exceeded.')

    def timeout(self, err=None):
        spawn = self.spawn
    
        spawn.before = spawn._before.getvalue()
        spawn.after = TIMEOUT
        index = self.searcher.timeout_index
        if index >= 0:
            spawn.match = TIMEOUT
            spawn.match_index = index
            return index
        else:
            spawn.match = None
            spawn.match_index = None
            msg = str(spawn)
            msg += '\nsearcher: %s' % self.searcher
            if err is not None:
                msg = str(err) + '\n' + msg
    
            exc = TIMEOUT(msg)
            exc.__cause__ = None    # in Python 3.x we can use "raise exc from None"
>           raise exc
E           pexpect.exceptions.TIMEOUT: Timeout exceeded.
E           <pexpect.pty_spawn.spawn object at 0x7f2119db8940>
E           command: /usr/bin/python3
E           args: ['/usr/bin/python3', '-mpytest', '--basetemp=/tmp/pytest-of-mockbuild/pytest-0/test_pdb_interaction_capturing_twice0/temp-pexpect', '/tmp/pytest-of-mockbuild/pytest-0/test_pdb_interaction_capturing_twice0/test_pdb_interaction_capturing_twice.py']
E           buffer (last 100 chars): b'n_capturing_twice0/test_pdb_interaction_capturing_twice.py(8)test_1()\r\n-> pytest.set_trace()\r\n(Pdb) '
E           before (last 100 chars): b'n_capturing_twice0/test_pdb_interaction_capturing_twice.py(8)test_1()\r\n-> pytest.set_trace()\r\n(Pdb) '
E           after: <class 'pexpect.exceptions.TIMEOUT'>
E           match: None
E           match_index: None
E           exitstatus: None
E           flag_eof: False
E           pid: 8768
E           child_fd: 20
E           closed: False
E           timeout: 10.0
E           delimiter: <class 'pexpect.exceptions.EOF'>
E           logfile: <_io.BufferedWriter name='/tmp/pytest-of-mockbuild/pytest-0/test_pdb_interaction_capturing_twice0/spawn.out'>
E           logfile_read: None
E           logfile_send: None
E           maxread: 2000
E           ignorecase: False
E           searchwindowsize: None
E           delaybeforesend: 0.05
E           delayafterclose: 0.1
E           delayafterterminate: 0.1
E           searcher: searcher_re:
E               0: re.compile(b'x = 4')

/usr/lib/python3.10/site-packages/pexpect/expect.py:144: TIMEOUT

Comment 6 Miro Hrončok 2021-01-08 12:30:27 UTC
There are new failures.

Comment 7 Tomáš Hrnčiar 2021-01-14 15:21:28 UTC
Looks like there are new failures. 

=================================== FAILURES ===================================
_____________________ TestPDB.test_pdb_interaction_doctest _____________________

>       assert "\r\n'i=0.'\r\n" in child.before.decode("utf8")
E       assert "\r\n'i=0.'\r\n" in ") 'i=%i.' % i\r\n\x1b[?2004l\r'i=0.'\r\n\x1b[?2004h("
E        +  where ") 'i=%i.' % i\r\n\x1b[?2004l\r'i=0.'\r\n\x1b[?2004h(" = <built-in method decode of bytes object at 0x7f4483068b70>('utf8')
E        +    where <built-in method decode of bytes object at 0x7f4483068b70> = b") 'i=%i.' % i\r\n\x1b[?2004l\r'i=0.'\r\n\x1b[?2004h(".decode
E        +      where b") 'i=%i.' % i\r\n\x1b[?2004l\r'i=0.'\r\n\x1b[?2004h(" = <pexpect.pty_spawn.spawn object at 0x7f4483095ca0>.before



___________________ TestPDB.test_pdb_with_injected_do_debug ____________________
>           raise exc
E           pexpect.exceptions.TIMEOUT: Timeout exceeded.
E           <pexpect.pty_spawn.spawn object at 0x7f448308ddc0>
E           command: /usr/bin/python3
E           args: ['/usr/bin/python3', '-mpytest', '--basetemp=/tmp/pytest-of-mockbuild/pytest-0/test_pdb_with_injected_do_debug0/temp-pexpect', '--pdbcls=mytest:CustomPdb', '/tmp/pytest-of-mockbuild/pytest-0/test_pdb_with_injected_do_debug0/mytest.py']
E           buffer (last 100 chars): b'-mockbuild/pytest-0/test_pdb_with_injected_do_debug0/mytest.py(34)test_1()\r\n-> x = 3\r\n\x1b[?2004h(Pdb) '
E           before (last 100 chars): b'-mockbuild/pytest-0/test_pdb_with_injected_do_debug0/mytest.py(34)test_1()\r\n-> x = 3\r\n\x1b[?2004h(Pdb) '
E           after: <class 'pexpect.exceptions.TIMEOUT'>
E           match: None
E           match_index: None
E           exitstatus: None
E           flag_eof: False
E           pid: 762
E           child_fd: 22
E           closed: False
E           timeout: 10.0
E           delimiter: <class 'pexpect.exceptions.EOF'>
E           logfile: <_io.BufferedWriter name='/tmp/pytest-of-mockbuild/pytest-0/test_pdb_with_injected_do_debug0/spawn.out'>
E           logfile_read: None
E           logfile_send: None
E           maxread: 2000
E           ignorecase: False
E           searchwindowsize: None
E           delaybeforesend: 0.05
E           delayafterclose: 0.1
E           delayafterterminate: 0.1
E           searcher: searcher_re:
E               0: re.compile(b'\\n\\(Pdb')

_______________ TestPDB.test_pdb_continue_with_recursive_debug[] _______________
>       assert "\r\nENTERING RECURSIVE DEBUGGER\r\n" in before
E       AssertionError: assert '\r\nENTERING RECURSIVE DEBUGGER\r\n' in '\r\n\x1b[?2004hdebug set_trace()\r\n\x1b[?2004l\rENTERING RECURSIVE DEBUGGER\r\n'

______________ TestPDB.test_pdb_continue_with_recursive_debug[-s] ______________

>       assert "\r\nENTERING RECURSIVE DEBUGGER\r\n" in before
E       AssertionError: assert '\r\nENTERING RECURSIVE DEBUGGER\r\n' in '\r\n\x1b[?2004hdebug set_trace()\r\n\x1b[?2004l\rENTERING RECURSIVE DEBUGGER\r\n'

________ TestPDB.test_pdb_continue_with_recursive_debug[-p no:capture] _________

>       assert "\r\nENTERING RECURSIVE DEBUGGER\r\n" in before
E       AssertionError: assert '\r\nENTERING RECURSIVE DEBUGGER\r\n' in '\r\n\x1b[?2004hdebug set_trace()\r\n\x1b[?2004l\rENTERING RECURSIVE DEBUGGER\r\n'

__________________ test_pdb_suspends_fixture_capturing[capfd] __________________

>       assert "\r\n42\r\n" in child.before.decode("utf8")
E       AssertionError: assert '\r\n42\r\n' in ') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h('
E        +  where ') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h(' = <built-in method decode of bytes object at 0x7f448313eb70>('utf8')
E        +    where <built-in method decode of bytes object at 0x7f448313eb70> = b') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h('.decode
E        +      where b') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h(' = <pexpect.pty_spawn.spawn object at 0x7f4482e61910>.before

_________________ test_pdb_suspends_fixture_capturing[capsys] __________________

>       assert "\r\n42\r\n" in child.before.decode("utf8")
E       AssertionError: assert '\r\n42\r\n' in ') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h('
E        +  where ') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h(' = <built-in method decode of bytes object at 0x7f4482fbb300>('utf8')
E        +    where <built-in method decode of bytes object at 0x7f4482fbb300> = b') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h('.decode
E        +      where b') p 40 + 2\r\n\x1b[?2004l\r42\r\n\x1b[?2004h(' = <pexpect.pty_spawn.spawn object at 0x7f4482fa1bb0>.before

=========================== short test summary info ============================
FAILED testing/test_debugging.py::TestPDB::test_pdb_interaction_doctest - ass...
FAILED testing/test_debugging.py::TestPDB::test_pdb_interaction_capturing_twice
FAILED testing/test_debugging.py::TestPDB::test_pdb_with_injected_do_debug - ...
FAILED testing/test_debugging.py::TestPDB::test_pdb_continue_with_recursive_debug[]
FAILED testing/test_debugging.py::TestPDB::test_pdb_continue_with_recursive_debug[-s]
FAILED testing/test_debugging.py::TestPDB::test_pdb_continue_with_recursive_debug[-p no:capture]
FAILED testing/test_debugging.py::test_pdb_suspends_fixture_capturing[capfd]
FAILED testing/test_debugging.py::test_pdb_suspends_fixture_capturing[capsys]

Comment 8 Miro Hrončok 2021-01-19 17:50:42 UTC
the escape sequences: https://github.com/pytest-dev/pytest/issues/8256

Comment 9 Ben Cotton 2021-02-09 15:22:06 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 10 Miro Hrončok 2021-02-18 23:04:36 UTC
Appears to be solved: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/pytest/


Note You need to log in before you can comment on or make changes to this bug.