Bug 1914847 - python-pytest4 fails to build with Python 3.10: ImportWarning: AssertionRewritingHook.exec_module() not found; falling back to load_module()
Summary: python-pytest4 fails to build with Python 3.10: ImportWarning: AssertionRewri...
Alias: None
Product: Fedora
Classification: Fedora
Component: python-pytest4
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Orphan Owner
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
Reported: 2021-01-11 10:36 UTC by Tomáš Hrnčiar
Modified: 2021-04-13 14:49 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2021-04-13 14:49:31 UTC
Type: Bug

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github pytest-dev pytest pull 8236 0 None open [4.6] Define create_module()/exec_module() in AssertionRewritingHook to avoid ImportWarning 2021-02-16 09:54:56 UTC

Description Tomáš Hrnčiar 2021-01-11 10:36:17 UTC
python-pytest4 fails to build with Python 3.10.0a4.

__________ ERROR collecting testing/python/show_fixtures_per_test.py ___________
/usr/lib/python3.10/site-packages/py/_path/local.py:704: in pyimport
<frozen importlib._bootstrap>:1026: in _find_and_load
<frozen importlib._bootstrap>:1005: in _find_and_load_unlocked
<frozen importlib._bootstrap>:681: in _load_unlocked
E   ImportWarning: AssertionRewritingHook.exec_module() not found; falling back to load_module()
!!!!!!!!!!!!!!!!!!! Interrupted: 59 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 59 error in 3.65 seconds ===========================

For the build logs, see:

For all our attempts to build python-pytest4 with Python 3.10, see:

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:

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 2021-01-11 10:59:40 UTC
This is hard to backport: https://github.com/pytest-dev/pytest/commit/4cd08f9b52e3ed984cf68b58abb6f7350623231f

I guess I'll just try to ignore the warning instead.

Comment 2 Miro Hrončok 2021-01-11 11:21:13 UTC
I've created https://github.com/pytest-dev/pytest/pull/8236 but there are still some failures:

=================================== FAILURES ===================================
_____________ TestAssertionRewriteHookDetails.test_reload_reloads ______________

self = <test_assertrewrite.TestAssertionRewriteHookDetails object at 0x7f9bc9d46e20>
testdir = <Testdir local('/tmp/pytest-of-mockbuild/pytest-3/test_reload_reloads0')>

    def test_reload_reloads(self, testdir):
        """Reloading a module after change picks up the change."""
            def reloaded():
                return False
            def rewrite_self():
                with open(__file__, 'w') as self:
                    self.write('def reloaded(): return True')
            python_files = *.py
            import sys
                from imp import reload
            except ImportError:
            def test_loader():
                import file
                assert not file.reloaded()
                assert file.reloaded()
        result = testdir.runpytest("-s")
>       result.stdout.fnmatch_lines(["* 1 passed*"])
E       Failed: nomatch: '* 1 passed*'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.10.0a4, pytest-4.6.11, py-1.10.0, pluggy-0.13.1'
E           and: 'rootdir: /tmp/pytest-of-mockbuild/pytest-3/test_reload_reloads0, inifile: pytest.ini'
E           and: 'plugins: hypothesis-5.41.3'
E           and: 'collected 1 item'
E           and: ''
E           and: 'test_fun.py F'
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '_________________________________ test_loader __________________________________'
E           and: ''
E           and: '    def test_loader():'
E           and: '        import file'
E           and: '        assert not file.reloaded()'
E           and: '        file.rewrite_self()'
E           and: '        reload(file)'
E           and: '>       assert file.reloaded()'
E           and: 'E       AssertionError: assert False'
E           and: 'E        +  where False = <function reloaded at 0x7f9bc9d65790>()'
E           and: "E        +    where <function reloaded at 0x7f9bc9d65790> = <module 'file' (<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7f9bc817eeb0>)>.reloaded"
E           and: ''
E           and: 'test_fun.py:12: AssertionError'
E           and: '=========================== 1 failed in 0.01 seconds ==========================='
E           and: ''
E       remains unmatched: '* 1 passed*'

/builddir/build/BUILD/pytest-4.6.11/testing/test_assertrewrite.py:1142: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.0a4, pytest-4.6.11, py-1.10.0, pluggy-0.13.1
rootdir: /tmp/pytest-of-mockbuild/pytest-3/test_reload_reloads0, inifile: pytest.ini
plugins: hypothesis-5.41.3
collected 1 item

test_fun.py F

=================================== FAILURES ===================================
_________________________________ test_loader __________________________________

    def test_loader():
        import file
        assert not file.reloaded()
>       assert file.reloaded()
E       AssertionError: assert False
E        +  where False = <function reloaded at 0x7f9bc9d65790>()
E        +    where <function reloaded at 0x7f9bc9d65790> = <module 'file' (<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7f9bc817eeb0>)>.reloaded

test_fun.py:12: AssertionError
=========================== 1 failed in 0.01 seconds ===========================

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

Comment 4 Miro Hrončok 2021-02-18 22:54:48 UTC
At this point, I think we should just skip the failing tests and/or orphan the package.

See also https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/6IVE4XM5UPZOXNRSRIWQL5PF4RA4QEOS/

Comment 5 Miro Hrončok 2021-04-13 14:49:31 UTC
Automation has figured out the package is retired in rawhide.

If you like it to be unretired, please open a ticket at https://pagure.io/releng/new_issue?template=package_unretirement

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