summaryrefslogtreecommitdiff
path: root/tests/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-12-27 16:56:32 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-12-27 17:52:41 -0500
commit5dbbe1430c16fe15b553e6909be8be5f2b9b71b9 (patch)
tree71c3e52b48ec793c48743e8b4c178326250b0f41 /tests/test_api.py
parent8240c58c90a0157178e9c5f6fedd9f003aab892d (diff)
downloadpython-coveragepy-git-5dbbe1430c16fe15b553e6909be8be5f2b9b71b9.tar.gz
Warnings can be marked to only display once.
Diffstat (limited to 'tests/test_api.py')
-rw-r--r--tests/test_api.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 369324f7..63a0c7b1 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -532,12 +532,22 @@ class ApiTest(CoverageTest):
self.assertIn("Hello\n", out)
err = self.stderr()
- self.assertIn(textwrap.dedent("""\
- Coverage.py warning: Module sys has no Python source. (module-not-python)
- """), err)
+ self.assertIn(
+ "Coverage.py warning: Module sys has no Python source. (module-not-python)",
+ err
+ )
self.assertNotIn("module-not-imported", err)
self.assertNotIn("no-data-collected", err)
+ def test_warn_once(self):
+ cov = coverage.Coverage()
+ cov.load()
+ cov._warn("Warning, warning 1!", slug="bot", once=True)
+ cov._warn("Warning, warning 2!", slug="bot", once=True)
+ err = self.stderr()
+ self.assertIn("Warning, warning 1!", err)
+ self.assertNotIn("Warning, warning 2!", err)
+
def test_source_and_include_dont_conflict(self):
# A bad fix made this case fail: https://bitbucket.org/ned/coveragepy/issues/541
self.make_file("a.py", "import b\na = 1")