summaryrefslogtreecommitdiff
path: root/tests/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-01-04 16:02:29 -0500
committerNed Batchelder <ned@nedbatchelder.com>2020-01-04 16:07:52 -0500
commitaefe08b437d1ce9c4e0bbdd7dba69e7316ede313 (patch)
tree81c0c0d86f7d5f8bcb6edf13a8f68047c11f3cee /tests/test_api.py
parentacf063cfff09d26678709ce6894d605f4199db09 (diff)
downloadpython-coveragepy-git-aefe08b437d1ce9c4e0bbdd7dba69e7316ede313.tar.gz
Ensure file touching happens if nothing was measured. #884
Diffstat (limited to 'tests/test_api.py')
-rw-r--r--tests/test_api.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 287391cb..7e43a6bb 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -295,6 +295,21 @@ class ApiTest(CoverageTest):
with self.assertRaisesRegex(CoverageException, "No data to report."):
cov.report()
+ def test_completely_zero_reporting(self):
+ # https://github.com/nedbat/coveragepy/issues/884
+ # If nothing was measured, the file-touching didn't happen properly.
+ self.make_file("foo/bar.py", "print('Never run')")
+ self.make_file("test.py", "assert True")
+ cov = coverage.Coverage(source=["foo"])
+ self.start_import_stop(cov, "test")
+ cov.report()
+ # Name Stmts Miss Cover
+ # --------------------------------
+ # foo/bar.py 1 1 0%
+
+ last = self.last_line_squeezed(self.stdout()).replace("\\", "/")
+ self.assertEqual("foo/bar.py 1 1 0%", last)
+
def test_cov4_data_file(self):
cov4_data = (
"!coverage.py: This is a private format, don't read it directly!"