diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-12 17:18:49 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-13 07:26:43 -0400 |
commit | a219b17fd967de796b446bc8626a7822902d7fd7 (patch) | |
tree | 42dba819031689d6494c5d6ecd3ce26e01bf5f32 /tests/test_summary.py | |
parent | de00789a23dc030fbbcd4814ff3478c307b70bb4 (diff) | |
download | python-coveragepy-git-a219b17fd967de796b446bc8626a7822902d7fd7.tar.gz |
refactor: convert existing imports to start_stop_import
Diffstat (limited to 'tests/test_summary.py')
-rw-r--r-- | tests/test_summary.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/tests/test_summary.py b/tests/test_summary.py index 4dbd3c08..f233b2fb 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -674,18 +674,14 @@ class SummaryTest(UsingModulesMixin, CoverageTest): print("y") """) cov = coverage.Coverage(branch=True, source=["."]) - cov.start() - import main # pragma: nested # pylint: disable=unused-import, import-error - cov.stop() # pragma: nested + self.start_import_stop(cov, "main") report = self.get_report(cov).splitlines() assert "mybranch.py 5 5 2 0 0%" in report def run_TheCode_and_report_it(self): """A helper for the next few tests.""" cov = coverage.Coverage() - cov.start() - import TheCode # pragma: nested # pylint: disable=import-error, unused-import - cov.stop() # pragma: nested + self.start_import_stop(cov, "TheCode") return self.get_report(cov) def test_bug_203_mixed_case_listed_twice_with_rc(self): @@ -716,6 +712,7 @@ class SummaryTest(UsingModulesMixin, CoverageTest): print("In mod.pyw") """) cov = coverage.Coverage() + # start_import_stop can't import the .pyw file, so use the long form. cov.start() import start # pragma: nested # pylint: disable=import-error, unused-import cov.stop() # pragma: nested @@ -736,9 +733,7 @@ class SummaryTest(UsingModulesMixin, CoverageTest): # Run the program. cov = coverage.Coverage() - cov.start() - import main # pragma: nested # pylint: disable=unused-import, import-error - cov.stop() # pragma: nested + self.start_import_stop(cov, "main") report = self.get_report(cov).splitlines() assert "mod.py 1 0 100%" in report @@ -762,9 +757,7 @@ class SummaryTest(UsingModulesMixin, CoverageTest): # Run the program. cov = coverage.Coverage() - cov.start() - import main # pragma: nested # pylint: disable=unused-import, import-error - cov.stop() # pragma: nested + self.start_import_stop(cov, "main") # Put back the missing Python file. self.make_file("mod.py", "a = 1\n") @@ -851,9 +844,7 @@ class SummaryReporterConfigurationTest(CoverageTest): self.make_file("doit.py", "import file1, file2, file10") cov = Coverage(source=["."], omit=["doit.py"]) - cov.start() - import doit # pragma: nested # pylint: disable=import-error, unused-import - cov.stop() # pragma: nested + self.start_import_stop(cov, "doit") for name, value in options: cov.set_option(name, value) printer = SummaryReporter(cov) |