From 2afc907abac4fe413ac53e6854d433e1c03bf720 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 7 Nov 2021 18:22:06 -0500 Subject: [PATCH] refactor(test): convert eight tests to one parametrized test --- tests/test_process.py | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/tests/test_process.py b/tests/test_process.py index b6c09f664..1e6448648 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -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: @@ -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')