Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests without fixtures can cause false deadfixture positives #11

Closed
tawonga opened this issue Apr 3, 2018 · 0 comments
Closed

Tests without fixtures can cause false deadfixture positives #11

tawonga opened this issue Apr 3, 2018 · 0 comments

Comments

@tawonga
Copy link
Contributor

tawonga commented Apr 3, 2018

Nice plugin.

I stumbled across a glitch in --deadfixtures. If a test which does not use fixtures is found, then the fixtures used by subsequent tests are considered dead.

This test fails

def test_dont_list_fixture_used_after_test_which_does_not_use_fixtures(testdir, message_template):
    testdir.makepyfile("""
        import pytest
        @pytest.fixture()
        def same_file_fixture():
            return 1
            
        def test_no_fixture_used():
            assert True
        def test_simple(same_file_fixture):
            assert 1 == same_file_fixture
    """)

    result = testdir.runpytest('--dead-fixtures')
    message = message_template.format(
        'same_file_fixture',
        'est_dont_list_fixture_used_after_test_which_does_not_use_fixtures'
    )

    assert result.ret == 0
assert message not in result.stdout.str()

The fix seems simple and I will raise a pull request for your consideration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant