Skip to content

Commit

Permalink
add more coverage to unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
Anis Da Silva Campos committed Dec 23, 2023
1 parent b0aacd5 commit 74586ca
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/input/unused-import/mark_usesfixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pytest

from other_fixture import other_fixture_not_in_conftest


@pytest.mark.usefixtures("other_fixture_not_in_conftest")
def uses_imported_fixture_with_decorator():
assert True
5 changes: 5 additions & 0 deletions tests/input/unused-import/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import pytest


def test_no_using_module():
assert True
6 changes: 6 additions & 0 deletions tests/input/unused-import/other_fixture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest


@pytest.fixture
def other_fixture_not_in_conftest():
return True
12 changes: 12 additions & 0 deletions tests/test_unused_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ def test_conftest(self, enable_plugin):
for pytest to do its magic"""
self.run_linter(enable_plugin)
self.verify_messages(0 if enable_plugin else 1)

@pytest.mark.parametrize("enable_plugin", [True, False])
def test_module(self, enable_plugin):
"""an unused module import shall still be an error"""
self.run_linter(enable_plugin)
self.verify_messages(1)

@pytest.mark.parametrize("enable_plugin", [True, False])
def test_mark_usesfixtures(self, enable_plugin):
"""an unused module import shall still be an error"""
self.run_linter(enable_plugin)
self.verify_messages(0 if enable_plugin else 1)

0 comments on commit 74586ca

Please sign in to comment.