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 | 521be8203abbcb8308311dd1584b311e5b476f1a (patch) | |
tree | 0eb222cc03b6dc2050dabb33ce2aab248b4919b3 /tests/test_html.py | |
parent | 8ab5ac1c524ed0423bbfb655d2e3c7d4cc4902f3 (diff) | |
download | python-coveragepy-git-521be8203abbcb8308311dd1584b311e5b476f1a.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 9c230c01..41859382 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() |