Skip to content

Commit d5aa5d7

Browse files
committed
refactor: these tests are better as parameterizations
1 parent f5ae0e6 commit d5aa5d7

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

tests/test_api.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,8 @@ class TestRunnerPluginTest(CoverageTest):
11411141
11421142
"""
11431143

1144-
def pretend_to_be_nose_with_cover(self, erase: bool = False, cd: bool = False) -> None:
1144+
@pytest.mark.parametrize("erase, cd", [(False, False), (True, False), (False, True)])
1145+
def test_pretend_to_be_nose_with_cover(self, erase: bool, cd: bool) -> None:
11451146
"""This is what the nose --with-cover plugin does."""
11461147
self.make_file(
11471148
"no_biggie.py",
@@ -1175,17 +1176,8 @@ def pretend_to_be_nose_with_cover(self, erase: bool = False, cd: bool = False) -
11751176
if cd:
11761177
os.chdir("..")
11771178

1178-
def test_nose_plugin(self) -> None:
1179-
self.pretend_to_be_nose_with_cover()
1180-
1181-
def test_nose_plugin_with_erase(self) -> None:
1182-
self.pretend_to_be_nose_with_cover(erase=True)
1183-
1184-
def test_nose_plugin_with_cd(self) -> None:
1185-
# https://github.com/coveragepy/coveragepy/issues/916
1186-
self.pretend_to_be_nose_with_cover(cd=True)
1187-
1188-
def pretend_to_be_pytestcov(self, append: bool) -> None:
1179+
@pytest.mark.parametrize("append", [False, True])
1180+
def test_pretend_to_be_pytestcov(self, append: bool) -> None:
11891181
"""Act like pytest-cov."""
11901182
self.make_file(
11911183
"prog.py",
@@ -1227,12 +1219,6 @@ def pretend_to_be_pytestcov(self, append: bool) -> None:
12271219
self.assert_file_count(".coverage", 0)
12281220
self.assert_file_count(".coverage.*", 1)
12291221

1230-
def test_pytestcov_parallel(self) -> None:
1231-
self.pretend_to_be_pytestcov(append=False)
1232-
1233-
def test_pytestcov_parallel_append(self) -> None:
1234-
self.pretend_to_be_pytestcov(append=True)
1235-
12361222

12371223
class ImmutableConfigTest(CoverageTest):
12381224
"""Check that reporting methods don't permanently change the configuration."""

0 commit comments

Comments
 (0)