SF.net SVN: docutils:[9966 ] trunk/docutils/test
milde--- via Docutils-checkins <[email protected]>
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 9966
http://sourceforge.net/p/docutils/code/9966
Author: milde
Date: 2024-10-22 21:41:26 +0000 (Tue, 22 Oct 2024)
Log Message:
-----------
Review conditional test cases.
Skip tests instead of deleting samples from `totests` dictionary if
requirements for the tested feature are missing.
This way we have a record in the test output.
Reformat a skip decorator and "assertRaises" block in test_get_parser_class.py.
Modified Paths:
--------------
trunk/docutils/test/test_parsers/test_get_parser_class.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
trunk/docutils/test/test_writers/test_html4css1.py
trunk/docutils/test/test_writers/test_html5_polyglot.py
Modified: trunk/docutils/test/test_parsers/test_get_parser_class.py
===================================================================
--- trunk/docutils/test/test_parsers/test_get_parser_class.py 2024-10-22 21:41:16 UTC (rev 9965)
+++ trunk/docutils/test/test_parsers/test_get_parser_class.py 2024-10-22 21:41:26 UTC (rev 9966)
@@ -50,14 +50,13 @@
# raises ImportError on failure
[email protected](md_parser_class is not None,
- 'Optional "recommonmark" module found.')
[email protected](md_parser_class is None, '"recommonmark" module found.')
class RecommonmarkMissingTests(unittest.TestCase):
def test_missing_parser_message(self):
# match multiline message (?s) = re.DOTALL "." also matches newline
- with self.assertRaisesRegex(ImportError,
- '(?s)requires the.*package .*recommonmark'):
+ with self.assertRaisesRegex(
+ ImportError, '(?s)requires the.*package .*recommonmark'):
publish_string('test data', parser='recommonmark')
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2024-10-22 21:41:16 UTC (rev 9965)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2024-10-22 21:41:26 UTC (rev 9966)
@@ -33,14 +33,13 @@
class ParserTestCase(unittest.TestCase):
def test_parser(self):
- if not with_pygments:
- del totest['code_parsing']
-
parser = Parser()
settings = get_default_settings(Parser)
settings.warning_stream = ''
settings.report_level = 5
for name, cases in totest.items():
+ if name == 'code_parsing' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
document = new_document('test data', settings.copy())
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2024-10-22 21:41:16 UTC (rev 9965)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2024-10-22 21:41:26 UTC (rev 9966)
@@ -40,12 +40,6 @@
maxDiff = None
def test_parser(self):
- # eventually skip optional parts:
- if not with_pygments:
- del totest['include_parsed_code']
- if not md_parser_class:
- del totest['include_markdown']
-
parser = Parser()
settings = get_default_settings(Parser)
settings.warning_stream = ''
@@ -53,6 +47,11 @@
for name, cases in totest.items():
if name == 'with transforms':
continue # see test_publish() below
+ # eventually skip optional parts:
+ if name == 'include_markdown' and not md_parser_class:
+ self.skipTest('no markdown parser available')
+ if name == 'include_parsed_code' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
document = new_document('test data', settings.copy())
Modified: trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2024-10-22 21:41:16 UTC (rev 9965)
+++ trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2024-10-22 21:41:26 UTC (rev 9966)
@@ -25,13 +25,12 @@
class ParserTestCase(unittest.TestCase):
def test_parser(self):
- if not with_pygments:
- del totest['code_parsing']
-
parser = Parser()
settings = get_default_settings(Parser)
settings.warning_stream = ''
for name, cases in totest.items():
+ if name == 'code_parsing' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
document = new_document('test data', settings.copy())
Modified: trunk/docutils/test/test_writers/test_html4css1.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1.py 2024-10-22 21:41:16 UTC (rev 9965)
+++ trunk/docutils/test/test_writers/test_html4css1.py 2024-10-22 21:41:26 UTC (rev 9966)
@@ -32,6 +32,7 @@
# pygments output changed in version 2.14
with_pygments = False
+
# TEST_ROOT is ./test/ from the docutils root
TEST_ROOT = Path(__file__).parents[1]
DATA_ROOT = TEST_ROOT / 'data'
@@ -50,9 +51,9 @@
maxDiff = None
def test_publish(self):
- if not with_pygments:
- del totest['syntax_highlight']
for name, (settings_overrides, cases) in totest.items():
+ if name == 'syntax_highlight' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
parts = docutils.core.publish_parts(
Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-10-22 21:41:16 UTC (rev 9965)
+++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-10-22 21:41:26 UTC (rev 9966)
@@ -73,9 +73,9 @@
maxDiff = None
def test_publish(self):
- if not with_pygments:
- del totest['syntax_highlight']
for name, (settings_overrides, cases) in totest.items():
+ if name == 'syntax_highlight' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
parts = docutils.core.publish_parts(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.