diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-12-21 07:59:14 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-12-21 07:59:14 -0500 |
commit | c83032da703361e6235aa551eccaab40ad5f7c51 (patch) | |
tree | 67bc5105887a0592c53b6f5f5b8eaa635e6d007e /tests/test_html.py | |
parent | ea7b292810c5c6eda5df93a33e287e9a29da825c (diff) | |
download | python-coveragepy-c83032da703361e6235aa551eccaab40ad5f7c51.tar.gz |
Use assertRaises as a context manager now that we can.
Diffstat (limited to 'tests/test_html.py')
-rw-r--r-- | tests/test_html.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/tests/test_html.py b/tests/test_html.py index 9c230c0..4185938 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -216,11 +216,9 @@ class HtmlWithUnparsableFilesTest(CoverageTest): cov = coverage.coverage() self.start_import_stop(cov, "innocuous") self.make_file("innocuous.py", "<h1>This isn't python!</h1>") - self.assertRaisesRegexp( - NotPython, - "Couldn't parse '.*innocuous.py' as Python source: '.*' at line 1", - cov.html_report - ) + msg = "Couldn't parse '.*innocuous.py' as Python source: .* at line 1" + with self.assertRaisesRegexp(NotPython, msg): + cov.html_report() def test_dotpy_not_python_ignored(self): self.make_file("innocuous.py", "a = 2") @@ -284,11 +282,9 @@ class HtmlTest(CoverageTest): missing_file = os.path.join(self.temp_dir, "sub", "another.py") missing_file = os.path.realpath(missing_file) - self.assertRaisesRegexp( - NoSource, - "(?i)No source for code: '%s'" % re.escape(missing_file), - cov.html_report - ) + msg = "(?i)No source for code: '%s'" % re.escape(missing_file) + with self.assertRaisesRegexp(NoSource, msg): + cov.html_report() class HtmlStaticFileTest(CoverageTest): """Tests of the static file copying for the HTML report.""" @@ -343,7 +339,6 @@ class HtmlStaticFileTest(CoverageTest): self.make_file("main.py", "print(17)") cov = coverage.coverage() self.start_import_stop(cov, "main") - self.assertRaisesRegexp( - CoverageException, "Couldn't find static file '.*'", - cov.html_report - ) + msg = "Couldn't find static file '.*'" + with self.assertRaisesRegexp(CoverageException, msg): + cov.html_report() |