Bug 1892612
Summary: | pytest fails to build with Python 3.10: AssertionError: assert '' == '{{ h()}}:' + timeout | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Tomáš Hrnčiar <thrnciar> |
Component: | pytest | Assignee: | Miro Hrončok <mhroncok> |
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | dradez, mhroncok, mrunge, thomas.moschny, thrnciar |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2021-02-18 23:04:36 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | 1914843 | ||
Bug Blocks: | 1890881 |
Description
Tomáš Hrnčiar
2020-10-29 10:28:45 UTC
Seems like a exception message difference only. Might be fixed upstream in newer versions, I will check/report/fix. Seems to be fixed in https://github.com/pytest-dev/pytest/commit/d9ac2efbcdee123f73edf1829c8bd6a91be3b6d2 (not yet released) Backporting the patch, also to pytest4. 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 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 There are new failures. 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] the escape sequences: https://github.com/pytest-dev/pytest/issues/8256 This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle. Changing version to 34. Appears to be solved: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/pytest/ |