summaryrefslogtreecommitdiff
path: root/docutils/test/DocutilsTestSupport.py
diff options
context:
space:
mode:
authoraa-turner <aa-turner@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-10-21 13:50:56 +0000
committeraa-turner <aa-turner@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-10-21 13:50:56 +0000
commit4e88264a5c91cf92fed2fce8015047545b30f3f8 (patch)
treea5bb6f1f70c4ac270fde1b7f27bef9e8668dff4d /docutils/test/DocutilsTestSupport.py
parent980a333f527e614f2690517364b2abe785bae133 (diff)
downloaddocutils-4e88264a5c91cf92fed2fce8015047545b30f3f8.tar.gz
Remove ``run_in_debugger``
To debug a specific test, use the facilities provided by ``unittest`` git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9166 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test/DocutilsTestSupport.py')
-rw-r--r--docutils/test/DocutilsTestSupport.py104
1 files changed, 17 insertions, 87 deletions
diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py
index 9ee960826..3dbb23072 100644
--- a/docutils/test/DocutilsTestSupport.py
+++ b/docutils/test/DocutilsTestSupport.py
@@ -109,8 +109,7 @@ class CustomTestCase(unittest.TestCase):
maxDiff = None
- def __init__(self, method_name, input, expected, id,
- run_in_debugger=True, suite_settings=None):
+ def __init__(self, method_name, input, expected, id, suite_settings=None):
"""
Initialise the CustomTestCase.
@@ -120,13 +119,11 @@ class CustomTestCase(unittest.TestCase):
input -- input to the parser.
expected -- expected output from the parser.
id -- unique test identifier, used by the test framework.
- run_in_debugger -- if true, run this test under the pdb debugger.
suite_settings -- settings overrides for this test suite.
"""
self.id = id
self.input = input
self.expected = expected
- self.run_in_debugger = run_in_debugger
if suite_settings is not None:
self.suite_settings = suite_settings.copy()
else:
@@ -213,7 +210,7 @@ class CustomTestSuite(unittest.TestSuite):
self.id = id
def addTestCase(self, test_case_class, method_name, input, expected,
- id=None, run_in_debugger=False, **kwargs):
+ id=None, **kwargs):
"""
Create a CustomTestCase in the CustomTestSuite.
Also return it, just in case.
@@ -225,7 +222,6 @@ class CustomTestSuite(unittest.TestSuite):
input -- input to the parser.
expected -- expected output from the parser.
id -- unique test identifier, used by the test framework.
- run_in_debugger -- if true, run this test under the pdb debugger.
"""
if id is None: # generate id if required
id = self.next_test_case_id
@@ -234,7 +230,6 @@ class CustomTestSuite(unittest.TestSuite):
tcid = '%s: %s' % (self.id, id)
# generate and add test case
tc = test_case_class(method_name, input, expected, tcid,
- run_in_debugger=run_in_debugger,
suite_settings=self.suite_settings.copy(),
**kwargs)
self.addTest(tc)
@@ -273,8 +268,6 @@ class TransformTestCase(CustomTestCase):
return True
def test_transforms(self):
- if self.run_in_debugger:
- pdb.set_trace()
settings = self.settings.copy()
settings.__dict__.update(self.suite_settings)
document = utils.new_document('test data', settings)
@@ -289,8 +282,6 @@ class TransformTestCase(CustomTestCase):
self.compare_output(self.input, output, self.expected)
def test_transforms_verbosely(self):
- if self.run_in_debugger:
- pdb.set_trace()
print('\n', self.id)
print('-' * 70)
print(self.input)
@@ -332,31 +323,18 @@ class TransformTestSuite(CustomTestSuite):
Each dictionary key (test type's name) maps to a tuple, whose
first item is a list of transform classes and whose second
item is a list of tests. Each test is a list: input, expected
- output, optional modifier. The optional third entry, a
- behavior modifier, can be 0 (temporarily disable this test) or
- 1 (run this test under the pdb debugger). Tests should be
- self-documenting and not require external comments.
+ output.
+ Tests should be self-documenting and not require external comments.
"""
for name, (transforms, cases) in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = False
- if len(case) == 3:
- # TODO: (maybe) change the 3rd argument to a dict, so it
- # can handle more cases by keyword ('disable', 'debug',
- # 'settings'), here and in other generateTests methods.
- # But there's also the method that
- # HtmlPublishPartsTestSuite uses <DJG>
- if case[2]:
- run_in_debugger = True
- else:
- continue
self.addTestCase(
TransformTestCase, testmethod,
transforms=transforms, parser=self.parser,
input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger)
+ id='%s[%r][%s]' % (dictname, name, casenum)
+ )
class ParserTestCase(CustomTestCase):
@@ -378,8 +356,6 @@ class ParserTestCase(CustomTestCase):
settings.debug = False
def test_parser(self):
- if self.run_in_debugger:
- pdb.set_trace()
settings = self.settings.copy()
settings.__dict__.update(self.suite_settings)
document = utils.new_document('test data', settings)
@@ -405,25 +381,17 @@ class ParserTestSuite(CustomTestSuite):
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: input, expected output, optional modifier. The
- optional third entry, a behavior modifier, can be 0 (temporarily
- disable this test) or 1 (run this test under the pdb debugger). Tests
- should be self-documenting and not require external comments.
+ test is a list: input, expected output.
+ Tests should be self-documenting and not require external comments.
"""
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = False
- if len(case) == 3:
- if case[2]:
- run_in_debugger = True
- else:
- continue
self.addTestCase(
self.test_case_class, 'test_parser',
input=case[0], expected=case[1],
id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger)
+ )
class PEPParserTestCase(ParserTestCase):
@@ -529,28 +497,18 @@ class GridTableParserTestSuite(CustomTestSuite):
Each dictionary key (test type name) maps to a list of tests. Each
test is a list: an input table, expected output from parse_table(),
- expected output from parse(), optional modifier. The optional fourth
- entry, a behavior modifier, can be 0 (temporarily disable this test)
- or 1 (run this test under the pdb debugger). Tests should be
- self-documenting and not require external comments.
+ expected output from parse().
+ Tests should be self-documenting and not require external comments.
"""
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = False
- if len(case) == 4:
- if case[-1]:
- run_in_debugger = True
- else:
- continue
self.addTestCase(self.test_case_class, 'test_parse_table',
input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger)
+ id='%s[%r][%s]' % (dictname, name, casenum))
self.addTestCase(self.test_case_class, 'test_parse',
input=case[0], expected=case[2],
- id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger)
+ id='%s[%r][%s]' % (dictname, name, casenum))
class SimpleTableParserTestCase(GridTableParserTestCase):
@@ -571,25 +529,15 @@ class SimpleTableParserTestSuite(CustomTestSuite):
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(), optional
- modifier. The optional third entry, a behavior modifier, can be 0
- (temporarily disable this test) or 1 (run this test under the pdb
- debugger). Tests should be self-documenting and not require external
- comments.
+ 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 in range(len(cases)):
case = cases[casenum]
- run_in_debugger = False
- if len(case) == 3:
- if case[-1]:
- run_in_debugger = True
- else:
- continue
self.addTestCase(self.test_case_class, 'test_parse',
input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger)
+ id='%s[%r][%s]' % (dictname, name, casenum))
class WriterPublishTestCase(CustomTestCase, docutils.SettingsSpec):
@@ -608,8 +556,6 @@ class WriterPublishTestCase(CustomTestCase, docutils.SettingsSpec):
super().__init__(*args, **kwargs)
def test_publish(self):
- if self.run_in_debugger:
- pdb.set_trace()
output = docutils.core.publish_string(
source=self.input,
reader_name='standalone',
@@ -634,17 +580,10 @@ class PublishTestSuite(CustomTestSuite):
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = False
- if len(case) == 3:
- if case[2]:
- run_in_debugger = True
- else:
- continue
self.addTestCase(
self.test_class, 'test_publish',
input=case[0], expected=case[1],
id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger,
# Passed to constructor of self.test_class:
writer_name=self.writer_name)
@@ -662,8 +601,6 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase):
settings_default_overrides['stylesheet'] = ''
def test_publish(self):
- if self.run_in_debugger:
- pdb.set_trace()
parts = docutils.core.publish_parts(
source=self.input,
reader_name='standalone',
@@ -730,16 +667,9 @@ class HtmlPublishPartsTestSuite(CustomTestSuite):
self.suite_settings.update(settings_overrides)
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = False
- if len(case) == 3:
- if case[2]:
- run_in_debugger = True
- else:
- continue
self.addTestCase(self.testcase_class, 'test_publish',
input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger)
+ id='%s[%r][%s]' % (dictname, name, casenum))
self.suite_settings = original_settings