diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-09 17:42:53 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-09 19:00:40 -0500 |
commit | 880a64afd24aae34eff2781f568d8ac9807d2ecc (patch) | |
tree | 802cf3368d4d7a1b27ee6b5d614c367ac691e320 /tests | |
parent | 8fef6f057c377879720c4c9d994e9651362a49b9 (diff) | |
download | python-coveragepy-git-880a64afd24aae34eff2781f568d8ac9807d2ecc.tar.gz |
fix: isolate user code from coverage.py internal code flags. #1524
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmdline.py | 2 | ||||
-rw-r--r-- | tests/test_summary.py | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 6caac307..c517d39d 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -142,7 +142,7 @@ class BaseCmdLineTest(CoverageTest): code = textwrap.dedent(code) expected = self.model_object() globs = {n: getattr(expected, n) for n in self.MOCK_GLOBALS} - code_obj = compile(code, "<code>", "exec") + code_obj = compile(code, "<code>", "exec", dont_inherit=True) eval(code_obj, globs, {}) # pylint: disable=eval-used # Many of our functions take a lot of arguments, and cmdline.py diff --git a/tests/test_summary.py b/tests/test_summary.py index 3109e90f..f532a7b1 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -849,6 +849,22 @@ class SummaryTest(UsingModulesMixin, CoverageTest): assert self.get_report(cov, output_format="total", precision=2) == "78.57\n" assert self.get_report(cov, output_format="total", precision=4) == "78.5714\n" + def test_bug_1524(self) -> None: + self.make_file("bug1524.py", """\ + class Mine: + @property + def thing(self) -> int: + return 17 + + print(Mine().thing) + """) + cov = coverage.Coverage() + self.start_import_stop(cov, "bug1524") + assert self.stdout() == "17\n" + report = self.get_report(cov) + report_lines = report.splitlines() + assert report_lines[2] == "bug1524.py 5 0 100%" + class ReportingReturnValueTest(CoverageTest): """Tests of reporting functions returning values.""" |