diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-10-03 16:34:52 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-10-03 16:34:52 -0400 |
commit | b27f9eab849696b46e9fbb84dcdc0f34078684d1 (patch) | |
tree | e55aacebb0b88fa430cf3b174f8eac041fbd4ef3 /tests/test_plugins.py | |
parent | 9a3c3e8b65070b31daf31cc149f28241cead89bf (diff) | |
download | python-coveragepy-git-b27f9eab849696b46e9fbb84dcdc0f34078684d1.tar.gz |
A better way to test for warnings.
Diffstat (limited to 'tests/test_plugins.py')
-rw-r--r-- | tests/test_plugins.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 06e3788d..54f26a7f 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -255,17 +255,11 @@ class PluginWarningOnPyTracer(CoverageTest): cov = coverage.Coverage() cov.set_option("run:plugins", ["tests.plugin1"]) - warnings = [] - def capture_warning(msg): - """A fake implementation of Coverage._warn, to capture warnings.""" - warnings.append(msg) - cov._warn = capture_warning - - self.start_import_stop(cov, "simple") - self.assertIn( - "Plugin file tracers (tests.plugin1.Plugin) aren't supported with PyTracer", - warnings - ) + expected_warnings = [ + r"Plugin file tracers \(tests.plugin1.Plugin\) aren't supported with PyTracer", + ] + with self.assert_warnings(cov, expected_warnings): + self.start_import_stop(cov, "simple") class FileTracerTest(CoverageTest): |