Bug 2272042 - copr-rpmbuild fails to build with pytest 8: AttributeError: 'NoneType' object has no attribute 'setup_method'
Summary: copr-rpmbuild fails to build with pytest 8: AttributeError: 'NoneType' object...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: copr-rpmbuild
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Copr Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2256331
TreeView+ depends on / blocked
 
Reported: 2024-03-28 12:02 UTC by Tomáš Hrnčiar
Modified: 2024-05-16 08:35 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-05-16 08:35:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2024-03-28 12:02:43 UTC
copr-rpmbuild fails to build with pytest 8.

==================================== ERRORS ====================================
___________ ERROR at setup of TestDistGitDownload.test_no_git_config ___________

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

    @classmethod
    def from_call(
        cls,
        func: Callable[[], TResult],
        when: Literal["collect", "setup", "call", "teardown"],
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        """Call func, wrapping the result in a CallInfo.
    
        :param func:
            The function to call. Called without arguments.
        :param when:
            The phase in which the function is called.
        :param reraise:
            Exception or exceptions that shall propagate if raised by the
            function, instead of being wrapped in the CallInfo.
        """
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

/usr/lib/python3.12/site-packages/_pytest/runner.py:340: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.12/site-packages/_pytest/runner.py:240: in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
/usr/lib/python3.12/site-packages/pluggy/_hooks.py:501: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
/usr/lib/python3.12/site-packages/pluggy/_manager.py:119: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/lib/python3.12/site-packages/_pytest/unraisableexception.py:85: in pytest_runtest_setup
    yield from unraisable_exception_runtest_hook()
/usr/lib/python3.12/site-packages/_pytest/unraisableexception.py:65: in unraisable_exception_runtest_hook
    yield
/usr/lib/python3.12/site-packages/_pytest/logging.py:843: in pytest_runtest_setup
    yield from self._runtest_for(item, "setup")
/usr/lib/python3.12/site-packages/_pytest/logging.py:832: in _runtest_for
    yield
/usr/lib/python3.12/site-packages/_pytest/capture.py:878: in pytest_runtest_setup
    return (yield)
/usr/lib/python3.12/site-packages/_pytest/threadexception.py:82: in pytest_runtest_setup
    yield from thread_exception_runtest_hook()
/usr/lib/python3.12/site-packages/_pytest/threadexception.py:63: in thread_exception_runtest_hook
    yield
/usr/lib/python3.12/site-packages/_pytest/runner.py:158: in pytest_runtest_setup
    item.session._setupstate.setup(item)
/usr/lib/python3.12/site-packages/_pytest/runner.py:515: in setup
    raise exc
/usr/lib/python3.12/site-packages/_pytest/runner.py:512: in setup
    col.setup()
/usr/lib/python3.12/site-packages/_pytest/python.py:1775: in setup
    self._request._fillfixtures()
/usr/lib/python3.12/site-packages/_pytest/fixtures.py:687: in _fillfixtures
    item.funcargs[argname] = self.getfixturevalue(argname)
/usr/lib/python3.12/site-packages/_pytest/fixtures.py:541: in getfixturevalue
    fixturedef = self._get_active_fixturedef(argname)
/usr/lib/python3.12/site-packages/_pytest/fixtures.py:570: in _get_active_fixturedef
    self._compute_fixture_value(fixturedef)
/usr/lib/python3.12/site-packages/_pytest/fixtures.py:647: in _compute_fixture_value
    fixturedef.execute(request=subrequest)
/usr/lib/python3.12/site-packages/_pytest/fixtures.py:1079: in execute
    result = ihook.pytest_fixture_setup(fixturedef=self, request=request)
/usr/lib/python3.12/site-packages/pluggy/_hooks.py:501: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
/usr/lib/python3.12/site-packages/pluggy/_manager.py:119: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/lib/python3.12/site-packages/_pytest/setuponly.py:36: in pytest_fixture_setup
    return (yield)
/usr/lib/python3.12/site-packages/_pytest/fixtures.py:1132: in pytest_fixture_setup
    result = call_fixture_func(fixturefunc, request, kwargs)
/usr/lib/python3.12/site-packages/_pytest/fixtures.py:906: in call_fixture_func
    fixture_result = next(generator)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

request = <SubRequest '_xunit_setup_method_fixture_TestDistGitDownload' for <Function test_no_git_config>>

    def xunit_setup_method_fixture(request) -> Generator[None, None, None]:
        instance = request.instance
        method = request.function
        if setup_method is not None:
>           func = getattr(instance, setup_name)
E           AttributeError: 'NoneType' object has no attribute 'setup_method'

/usr/lib/python3.12/site-packages/_pytest/python.py:847: AttributeError
=============================== warnings summary ===============================
../../../../usr/lib/python3.12/site-packages/munch/__init__.py:24
  /usr/lib/python3.12/site-packages/munch/__init__.py:24: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

tests/test_mock.py:20
  /builddir/build/BUILD/copr-rpmbuild-0.72/tests/test_mock.py:20: PytestDeprecationWarning: @pytest.yield_fixture is deprecated.
  Use @pytest.fixture instead; they are the same.
    @pytest.yield_fixture

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
ERROR tests/test_distgit_client.py::TestDistGitDownload::test_no_git_config
=================== 56 passed, 2 warnings, 1 error in 1.00s ====================

I think this could be related to this change. https://github.com/pytest-dev/pytest/commit/c8792bd0800b8ffc536a6ce251f9eb3075b5f5fa

https://docs.pytest.org/en/stable/changelog.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/thrnciar/pytest/fedora-rawhide-x86_64/07167809-copr-rpmbuild/

For all our attempts to build copr-rpmbuild with pytest 8, see:
https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/package/copr-rpmbuild/

Let us know here if you have any questions.

Pytest 8 is planned to be included in Fedora 41. This bugzilla is a
heads up before we merge new pytest into rawhide. For more info see a Fedora Change proposal https://fedoraproject.org/wiki/Changes/Pytest_8

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 Jakub Kadlčík 2024-04-10 11:51:14 UTC
Thank you for the report Tomáš,
much appreciated.

Modified in: https://github.com/fedora-copr/copr/pull/3213


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