diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-02-21 13:53:31 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-02-21 13:53:31 +0000 |
| commit | afff22f353d004e4e5baa879775a8e24cb5de5a2 (patch) | |
| tree | 44db7390a3a3fe059d971c7def9a6a69bfb3ba57 /docutils/test/test_parsers | |
| parent | 68f5aee63b74990f832e6cb89cbb7d0580860d23 (diff) | |
| download | docutils-afff22f353d004e4e5baa879775a8e24cb5de5a2.tar.gz | |
Simplify/modernise tests for exceptions and warnings.
Use unicode.assertWarnsRegex() instead of "hand written"
warnings catching.
Use unicode.assertRaises() as context manager
(unless this would mean an additional code line).
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9011 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test/test_parsers')
| -rw-r--r-- | docutils/test/test_parsers/test_get_parser_class.py | 4 | ||||
| -rw-r--r-- | docutils/test/test_parsers/test_recommonmark/test_misc.py | 11 |
2 files changed, 6 insertions, 9 deletions
diff --git a/docutils/test/test_parsers/test_get_parser_class.py b/docutils/test/test_parsers/test_get_parser_class.py index fec6a2bab..b1262cff5 100644 --- a/docutils/test/test_parsers/test_get_parser_class.py +++ b/docutils/test/test_parsers/test_get_parser_class.py @@ -21,8 +21,8 @@ class GetParserClassTestCase(DocutilsTestSupport.StandardTestCase): # raises ImportError on failure def test_bogus_parser(self): - self.assertRaises(ImportError, - get_parser_class, 'nope') + with self.assertRaises(ImportError): + get_parser_class('nope') def test_local_parser(self): # requires local-parser.py in test directory (testroot) diff --git a/docutils/test/test_parsers/test_recommonmark/test_misc.py b/docutils/test/test_parsers/test_recommonmark/test_misc.py index 4c7052c7a..02e7ba490 100644 --- a/docutils/test/test_parsers/test_recommonmark/test_misc.py +++ b/docutils/test/test_parsers/test_recommonmark/test_misc.py @@ -72,13 +72,10 @@ class RecommonmarkParserTests(unittest.TestCase): class RecommonmarkMissingTests(unittest.TestCase): def test_missing_parser_message(self): - try: - output = publish_string(sample_with_html, - parser_name='recommonmark') - except ImportError as err: - self.assertIn( - 'requires the package https://pypi.org/project/recommonmark', - str(err)) + with self.assertRaisesRegex(ImportError, + 'requires the package .*recommonmark'): + publish_string(sample_with_html, parser_name='recommonmark') + if __name__ == '__main__': unittest.main() |
