summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorEdward Loper <edloper@gradient.cis.upenn.edu>2004-08-09 16:14:41 (GMT)
committerEdward Loper <edloper@gradient.cis.upenn.edu>2004-08-09 16:14:41 (GMT)
commita1ef6110ba5355334431c76f6b4b3273a613aed2 (patch)
tree616966ef228587b5310cce824dc2623b16d6b103 /Lib/test
parent413ced6c226b5a89c45cf2f4da79126f75cb200b (diff)
downloadcpython-a1ef6110ba5355334431c76f6b4b3273a613aed2.zip
cpython-a1ef6110ba5355334431c76f6b4b3273a613aed2.tar.gz
cpython-a1ef6110ba5355334431c76f6b4b3273a613aed2.tar.bz2
- DocTest is now a simple container class; its constructor is no longer
responsible for parsing the string. - Renamed Parser to DocTestParser - DocTestParser.get_*() now accept the string & name as command-line arguments; the parser's constructor is now empty. - Added DocTestParser.get_doctest() method - Replaced "doctest_factory" argument to DocTestFinder with a "parser" argument (takes a DocTestParser). - Changed _tag_msg to take an indentation string argument.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_doctest.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 28b72cb..50da872 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -183,7 +183,9 @@ constructor:
... example
... '''
>>> globs = {} # globals to run the test in.
- >>> test = doctest.DocTest(docstring, globs, 'some_test', 'some_file', 20)
+ >>> parser = doctest.DocTestParser()
+ >>> test = parser.get_doctest(docstring, globs, 'some_test',
+ ... 'some_file', 20)
>>> print test
<DocTest some_test from some_file:20 (2 examples)>
>>> len(test.examples)
@@ -217,7 +219,7 @@ expected output of an example, then `DocTest` will raise a ValueError:
... bad
... indentation
... '''
- >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0)
+ >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last):
ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: ' indentation'
@@ -229,7 +231,7 @@ continuation lines, then `DocTest` will raise a ValueError:
... ... 2)
... ('bad', 'indentation')
... '''
- >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0)
+ >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last):
ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)'
@@ -237,7 +239,7 @@ If there's no blank space after a PS1 prompt ('>>>'), then `DocTest`
will raise a ValueError:
>>> docstring = '>>>print 1\n1'
- >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0)
+ >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last):
ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1'
@@ -245,7 +247,7 @@ If there's no blank space after a PS2 prompt ('...'), then `DocTest`
will raise a ValueError:
>>> docstring = '>>> if 1:\n...print 1\n1'
- >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0)
+ >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last):
ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1'
@@ -998,7 +1000,8 @@ def test_pdb_set_trace():
... >>> x = 42
... >>> import pdb; pdb.set_trace()
... '''
- >>> test = doctest.DocTest(doc, {}, "foo", "foo.py", 0)
+ >>> parser = doctest.DocTestParser()
+ >>> test = parser.get_doctest(doc, {}, "foo", "foo.py", 0)
>>> runner = doctest.DocTestRunner(verbose=False)
To demonstrate this, we'll create a fake standard input that
@@ -1040,7 +1043,7 @@ def test_pdb_set_trace():
... >>> x=1
... >>> calls_set_trace()
... '''
- >>> test = doctest.DocTest(doc, globals(), "foo", "foo.py", 0)
+ >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
>>> fake_stdin = tempfile.TemporaryFile(mode='w+')
>>> fake_stdin.write('\n'.join([