Skip to content

Commit b52f6f6

Browse files
author
Anis Da Silva Campos
committed
add more coverage to unused import
1 parent a82e532 commit b52f6f6

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pytest
2+
3+
from other_fixture import other_fixture_not_in_conftest
4+
5+
6+
@pytest.mark.usefixtures("other_fixture_not_in_conftest")
7+
def uses_imported_fixture_with_decorator():
8+
assert True

tests/input/unused-import/module.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import pytest
2+
3+
4+
def test_no_using_module():
5+
assert True
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def other_fixture_not_in_conftest():
6+
return True

tests/test_unused_import.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ def test_conftest(self, enable_plugin):
4040
for pytest to do its magic"""
4141
self.run_linter(enable_plugin)
4242
self.verify_messages(0 if enable_plugin else 1)
43+
44+
@pytest.mark.parametrize("enable_plugin", [True, False])
45+
def test_module(self, enable_plugin):
46+
"""an unused module import shall still be an error"""
47+
self.run_linter(enable_plugin)
48+
self.verify_messages(1)
49+
50+
@pytest.mark.parametrize("enable_plugin", [True, False])
51+
def test_mark_usesfixtures(self, enable_plugin):
52+
"""an unused module import shall still be an error"""
53+
self.run_linter(enable_plugin)
54+
self.verify_messages(0 if enable_plugin else 1)

0 commit comments

Comments
 (0)