pytest-dev / pytest-django

A Django plugin for pytest.
https://pytest-django.readthedocs.io/
Other
1.37k stars 344 forks source link

Replace `funcargnames` with `fixturenames` #1015

Closed mawilliam closed 2 years ago

mawilliam commented 2 years ago

The funcargnames attribute has been deprecated in favor of fixturenames since pytest 6.1. I received the following exception:

_______________ ERROR at setup of test_recurrence_end_count[1-1] _______________

request = <SubRequest '_live_server_helper' for <Function test_recurrence_end_count[1-1]>>

    @pytest.fixture(autouse=True, scope='function')
    def _live_server_helper(request):
        """Helper to make live_server work, internal to pytest-django.

        This helper will dynamically request the transactional_db fixture
        for a test which uses the live_server fixture.  This allows the
        server and test to access the database without having to mark
        this explicitly which is handy since it is usually required and
        matches the Django behaviour.

        The separate helper is required since live_server can not request
        transactional_db directly since it is session scoped instead of
        function-scoped.
        """
>       if 'live_server' in request.funcargnames:
E       AttributeError: 'SubRequest' object has no attribute 'funcargnames'

There are still four instances of it being used in the fixtures.py module including the one referenced in my exception. Updating that attribute reference fixed my error.

I am using Python 3.7 and pytest-django 3.1.2 on Mac Monterey version 12.3.1.

Please let me know if you need anything else. Thanks!

mawilliam commented 2 years ago

I use conda and when I searched for pytest-django, the results implied that 3.1.2 was the latest. I realize 4.5.2 is out there and has fixed this issue. Sorry for the hassle.