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 | 2884998748f95c222cecb1ad72a7bc404aedeae3 (patch) | |
| tree | 2c52c82133983de869ec59e5e76f2851e66d2d11 /tests/test_plugins.py | |
| parent | 894e95148082abf4ca4ed1242b62eb2ccf39442f (diff) | |
| download | python-coveragepy-2884998748f95c222cecb1ad72a7bc404aedeae3.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 06e3788..54f26a7 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): |
