diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2017-02-20 14:22:06 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-02-20 14:22:06 -0500 |
commit | 66af7e3d24084829850b8bb6d671ddb0094a0331 (patch) | |
tree | 5eccacaa10f35524c24f958f959e8a57547d2eb7 /tests/test_testing.py | |
parent | c59233e638cc632afc80251463ae9f391beea365 (diff) | |
download | python-coveragepy-git-66af7e3d24084829850b8bb6d671ddb0094a0331.tar.gz |
assert_warnings can now assert that there were no warnings.
Diffstat (limited to 'tests/test_testing.py')
-rw-r--r-- | tests/test_testing.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_testing.py b/tests/test_testing.py index 9776acb4..d86207ed 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -119,6 +119,19 @@ class CoverageTestTest(CoverageTest): with self.assert_warnings(cov, ["Hello there!"]): raise ZeroDivisionError("oops") + def test_assert_no_warnings(self): + cov = coverage.Coverage() + + # Happy path: no warnings. + with self.assert_warnings(cov, []): + pass + + # If you said there would be no warnings, and there were, fail! + warn_regex = r"Unexpected warnings: \['Watch out!'\]" + with self.assertRaisesRegex(AssertionError, warn_regex): + with self.assert_warnings(cov, []): + cov._warn("Watch out!") + def test_sub_python_is_this_python(self): # Try it with a Python command. self.set_environ('COV_FOOBAR', 'XYZZY') |