Skip to content

Commit

Permalink
refactor(test): convert eight tests to one parametrized test
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Nov 7, 2021
1 parent 2a2293c commit 2afc907
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,10 @@ class ProcessStartupWithSourceTest(ProcessCoverageMixin, CoverageTest):
"""

def assert_pth_and_source_work_together(
self, dashm, package, source
):
@pytest.mark.parametrize("dashm", ["-m", ""])
@pytest.mark.parametrize("package", ["pkg", ""])
@pytest.mark.parametrize("source", ["main", "sub"])
def test_pth_and_source_work_together(self, dashm, package, source):
"""Run the test for a particular combination of factors.
The arguments are all strings:
Expand Down Expand Up @@ -1641,27 +1642,3 @@ def path(basename):
summary = line_counts(data)
assert summary[source + '.py'] == 3
assert len(summary) == 1

def test_dashm_main(self):
self.assert_pth_and_source_work_together('-m', '', 'main')

def test_script_main(self):
self.assert_pth_and_source_work_together('', '', 'main')

def test_dashm_sub(self):
self.assert_pth_and_source_work_together('-m', '', 'sub')

def test_script_sub(self):
self.assert_pth_and_source_work_together('', '', 'sub')

def test_dashm_pkg_main(self):
self.assert_pth_and_source_work_together('-m', 'pkg', 'main')

def test_script_pkg_main(self):
self.assert_pth_and_source_work_together('', 'pkg', 'main')

def test_dashm_pkg_sub(self):
self.assert_pth_and_source_work_together('-m', 'pkg', 'sub')

def test_script_pkg_sub(self):
self.assert_pth_and_source_work_together('', 'pkg', 'sub')

0 comments on commit 2afc907

Please sign in to comment.