Skip to content

Inconsistent results for a test when running in-suite #842

Closed
@SHxKM

Description

@SHxKM
Python 3.6.8
pytest==5.4.2
pytest-django==3.9.0
pytest-forked==1.0.2
pytest-socket==0.3.3
pytest-xdist==1.29.0

It seems that one particular test outputs different results based on if I'm running the whole suite or not.

When running the test like so:

pytest -k "test_name_of_test_func"

The test passes. But the test fails if I run the whole suite:

pytest -vvv

I've been debugging this for the past few hours to no avail. I've removed --reuse-db --no-migrations and brought them back, no dice. The behaviour under test has been manually verified, and the test should definitely pass.

Some details:

The test uses indirect parametrization like so:

@pytest.mark.parametrize(
    "profile, expected",
    [("test_some", False), ("test_some_other", True)],
    indirect=["profile"],
)
def test_name_of_test_func(profile, client, expected)

Both test_some and test_some_other are fixtures defined in fixtures.py:

@pytest.fixture
def profile(request):
    return request.getfixturevalue(request.param)

@pytest.fixture(scope="function")
def test_some(db):
    # ...
@pytest.fixture(scope="function")
def test_some_other(db):
    # ...

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions