summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authoraa-turner <aa-turner@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-11-08 16:42:40 +0000
committeraa-turner <aa-turner@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-11-08 16:42:40 +0000
commitb97e552ab75dc4c6c91c5dfe5cefd564e6672bbb (patch)
tree309e52e9cc084e6ed3cbe4f79cd9d9bd4d67017e /docutils
parent460528d185dca5b4b2bbdac3123e9306ab18afab (diff)
downloaddocutils-b97e552ab75dc4c6c91c5dfe5cefd564e6672bbb.tar.gz
Inline ``SimpleTableParserTestSuite``
- Move all usages of ``SimpleTableParserTestSuite.generateTests`` to using subtests, as part of the test suite refactoring project git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9223 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/test/DocutilsTestSupport.py28
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_SimpleTableParser.py25
2 files changed, 19 insertions, 34 deletions
diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py
index f2fe7fa67..bf51026fc 100644
--- a/docutils/test/DocutilsTestSupport.py
+++ b/docutils/test/DocutilsTestSupport.py
@@ -22,8 +22,6 @@ Exports the following:
- `PEPParserTestSuite`
- `GridTableParserTestCase`
- `GridTableParserTestSuite`
- - `SimpleTableParserTestCase`
- - `SimpleTableParserTestSuite`
- `WriterPublishTestCase`
- `PublishTestSuite`
"""
@@ -419,32 +417,6 @@ class GridTableParserTestSuite(CustomTestSuite):
id=f'totest[{name!r}][{casenum}]')
-class SimpleTableParserTestCase(GridTableParserTestCase):
-
- parser = tableparser.SimpleTableParser()
-
-
-class SimpleTableParserTestSuite(CustomTestSuite):
-
- """
- A collection of SimpleTableParserTestCases.
- """
-
- def generateTests(self, dict):
- """
- Stock the suite with test cases generated from a test data dictionary.
-
- Each dictionary key (test type name) maps to a list of tests. Each
- test is a list: an input table, expected output from parse().
- Tests should be self-documenting and not require external comments.
- """
- for name, cases in dict.items():
- for casenum, (case_input, case_expected) in enumerate(cases):
- self.addTestCase(SimpleTableParserTestCase, 'test_parse',
- input=case_input, expected=case_expected,
- id=f'totest[{name!r}][{casenum}]')
-
-
class WriterPublishTestCase(CustomTestCase, docutils.SettingsSpec):
"""
diff --git a/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py b/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py
index 65cacbf51..773fcdc67 100755
--- a/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py
+++ b/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py
@@ -7,13 +7,26 @@
Tests for states.py.
"""
-from test import DocutilsTestSupport
+import unittest
+from test import DocutilsTestSupport # NoQA: F401
-def suite():
- s = DocutilsTestSupport.SimpleTableParserTestSuite()
- s.generateTests(totest)
- return s
+from docutils.parsers.rst import tableparser
+from docutils.statemachine import StringList, string2lines
+
+
+class SimpleTableParserTestCase(unittest.TestCase):
+ def test_parse(self):
+ parser = tableparser.SimpleTableParser()
+ for name, cases in totest.items():
+ for casenum, (case_input, case_expected) in enumerate(cases):
+ lines_input = StringList(string2lines(case_input), 'test data')
+ with self.subTest(id=f'totest[{name!r}][{casenum}]'):
+ try:
+ output = parser.parse(lines_input)
+ except Exception as details:
+ output = f'{details.__class__.__name__}: {details}'
+ self.assertEqual(output, case_expected)
totest = {}
@@ -145,4 +158,4 @@ That's bad.
if __name__ == '__main__':
import unittest
- unittest.main(defaultTest='suite')
+ unittest.main()