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 | 460272b31fc0c6fa017cc53d1d3f2233b2db4ba3 (patch) | |
| tree | 990046d385948d954bf028d14bcf722d2d581743 /tests/test_testing.py | |
| parent | fdc34b70eb34e9bcddc40a5498dd6f049ce0310a (diff) | |
| download | python-coveragepy-460272b31fc0c6fa017cc53d1d3f2233b2db4ba3.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 9776acb..d86207e 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') |
