summaryrefslogtreecommitdiff
path: root/tests/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-03-03 22:28:47 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-03-03 22:28:47 -0500
commitd679d5442ea8d39111e02b8d3251e34418287e50 (patch)
tree5f05ecc5a5d8a07063845f5797d02324a61eee6c /tests/test_api.py
parentc2b922448ac753630c3170eb2a5bd3a00016aa79 (diff)
downloadpython-coveragepy-git-d679d5442ea8d39111e02b8d3251e34418287e50.tar.gz
Collecting continues after saving data. #79 #448
Diffstat (limited to 'tests/test_api.py')
-rw-r--r--tests/test_api.py51
1 files changed, 49 insertions, 2 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 7530aca1..07f5506a 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -281,8 +281,7 @@ class ApiTest(CoverageTest):
self.start_import_stop(cov, "code2")
self.check_code1_code2(cov)
- def test_start_save_stop(self): # pragma: not covered
- self.skipTest("Expected failure: https://bitbucket.org/ned/coveragepy/issue/79")
+ def test_start_save_stop(self):
self.make_code1_code2()
cov = coverage.Coverage()
cov.start()
@@ -290,9 +289,57 @@ class ApiTest(CoverageTest):
cov.save()
import_local_file("code2")
cov.stop()
+ self.check_code1_code2(cov)
+ def test_start_save_nostop(self):
+ self.make_code1_code2()
+ cov = coverage.Coverage()
+ cov.start()
+ import_local_file("code1")
+ cov.save()
+ import_local_file("code2")
self.check_code1_code2(cov)
+ def test_two_getdata_only_warn_once(self):
+ self.make_code1_code2()
+ cov = coverage.Coverage(source=["."], omit=["code1.py"])
+ cov.start()
+ import_local_file("code1")
+ cov.stop()
+ # We didn't collect any data, so we should get a warning.
+ with self.assert_warnings(cov, ["No data was collected"]):
+ cov.get_data()
+ # But calling get_data a second time with no intervening activity
+ # won't make another warning.
+ with self.assert_warnings(cov, []):
+ cov.get_data()
+
+ def test_two_getdata_only_warn_once_nostop(self):
+ self.make_code1_code2()
+ cov = coverage.Coverage(source=["."], omit=["code1.py"])
+ cov.start()
+ import_local_file("code1")
+ # We didn't collect any data, so we should get a warning.
+ with self.assert_warnings(cov, ["No data was collected"]):
+ cov.get_data()
+ # But calling get_data a second time with no intervening activity
+ # won't make another warning.
+ with self.assert_warnings(cov, []):
+ cov.get_data()
+
+ def test_two_getdata_warn_twice(self):
+ self.make_code1_code2()
+ cov = coverage.Coverage(source=["."], omit=["code1.py", "code2.py"])
+ cov.start()
+ import_local_file("code1")
+ # We didn't collect any data, so we should get a warning.
+ with self.assert_warnings(cov, ["No data was collected"]):
+ cov.save()
+ import_local_file("code2")
+ # Calling get_data a second time after tracing some more will warn again.
+ with self.assert_warnings(cov, ["No data was collected"]):
+ cov.get_data()
+
def make_good_data_files(self):
"""Make some good data files."""
self.make_code1_code2()