You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pytest collection is not deterministic when there are parametrized fixtures involved, which will make test collection unpredictable and result in some tests being skipped. I wrote a shell script that does exactly this before I found out about the plugin. I solved it by sorting the tests after collecting them, hopefully it will help to you too.
Reproduction
Create a test with parameters in django-cookiecutter template. Note that I haven't tried with this exact setup but I'm 90% sure it will have the same issue.
# conftest.pyimportpytestfromdjango.utils.dateparseimportparse_datetimefromfakerimportFakerfromcpde.users.modelsimportUserfromcode.users.tests.factoriesimportUserFactoryfaker_uk=Faker(locale="en_GB")
Faker.seed()
naive_datetime_fuzz= [
pytest.param(
parse_datetime("2021-11-07T01:30:00"), marks=pytest.mark.fuzz
), # Naive datetime during US DST endpytest.param(
parse_datetime("2020-02-29T09:30:00"), marks=pytest.mark.fuzz
), # Leap Year Feb29thpytest.param(
parse_datetime("2021-11-07T00:00:00.000"), marks=pytest.mark.fuzz
), # Exactly midnightpytest.param(faker_uk.past_datetime()), # Recent time
]
@pytest.fixture(params=naive_datetime_fuzz)defnaive_datetime(request):
returnrequest.param@pytest.fixturedefuser(naive_datetime) ->User:
returnUserFactory(date_joined=naive_datetime)
Run the same portion a few times and note the different number of collected tests:
Issue
Pytest collection is not deterministic when there are parametrized fixtures involved, which will make test collection unpredictable and result in some tests being skipped. I wrote a shell script that does exactly this before I found out about the plugin. I solved it by sorting the tests after collecting them, hopefully it will help to you too.
Reproduction
Create a test with parameters in django-cookiecutter template. Note that I haven't tried with this exact setup but I'm 90% sure it will have the same issue.
Run the same portion a few times and note the different number of collected tests:
The text was updated successfully, but these errors were encountered: