pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.93k stars 2.65k forks source link

[Python 3.13.0b3] Address a deprecated call in `testing/python/fixtures.py::test_getfuncargnames_partial` #12552

Closed webknjaz closed 3 months ago

webknjaz commented 3 months ago
================================== FAILURES ===================================
________________________ test_getfuncargnames_partial _________________________

    def test_getfuncargnames_partial():
        """Check getfuncargnames for methods defined with functools.partial (#5701)"""
        import functools

        def check(arg1, arg2, i):
            raise NotImplementedError()

        class T:
            test_ok = functools.partial(check, i=2)

>       values = getfuncargnames(T().test_ok, name="test_ok")
E       FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior

testing\python\fixtures.py:89: FutureWarning

(https://github.com/pytest-dev/pytest/actions/runs/9745977844/job/26895224146#step:7:220)

ghost commented 3 months ago

Hello @webknjaz, From the warning, one fix is to replace functools.partial(check, i=2) with staticmethod(functools.partial(check, i=2)). But this is exactly what the next test case checks for. Do we get rid of test_getfuncargnames_partial entirely and rename test_getfuncargnames_staticmethod_partial to test_getfuncargnames_partial?

webknjaz commented 3 months ago

Dunno, but it seems like @Pierre-Sassoulas is about to do something about it..

webknjaz commented 3 months ago

Though, it'd be nice to submit that patch separately so that it could be backported easily.

ghost commented 3 months ago

Sure! The change mentioned skips the tests. I guess I'll submit a patch that does the same.

Pierre-Sassoulas commented 3 months ago

Feel free to cherry-pick or open another MR, I think the pre-commit tool update could be merged fast, but I didn't realize that python 3.13 need to be handled on backporting branches too.

webknjaz commented 3 months ago

@Pierre-Sassoulas FYI you never needed to fix the 3.13 problem as those jobs are not required to pass and don't block merging. There's a flaky pypy3 job, though, that might need to be restarted occasionally (the fix is in the works).