summaryrefslogtreecommitdiff
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorEdward Loper <edloper@gradient.cis.upenn.edu>2004-09-28 05:50:57 +0000
committerEdward Loper <edloper@gradient.cis.upenn.edu>2004-09-28 05:50:57 +0000
commit7d88a58e851d6c4b9ac61052d54041536a1ceddd (patch)
treead3c60aeaf01531524c1eabcd47900b433b4ed47 /Lib/test/test_doctest.py
parent4cda01e260b65dce2d9da73c45df1ecdcf4a798a (diff)
downloadcpython-git-7d88a58e851d6c4b9ac61052d54041536a1ceddd.tar.gz
Reverted the addition of a NORMALIZE_NUMBERS option, per Tim Peter's
request. Tim says that "correct 'fuzzy' comparison of floats cannot be automated." (The motivation behind adding the new option was verifying interactive examples in Python's latex documentation; several such examples use numbers that don't print consistently on different platforms.)
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py101
1 files changed, 0 insertions, 101 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index eb0b10cd78..d17ca1a401 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -1032,107 +1032,6 @@ treated as equal:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-The NORMALIZE_NUMBERS flag causes numbers that are equal (to
-approximately 10 decimal places) but formatted differently to match.
-
- >>> def f(x): '''
- ... Numbers will match if they are exactly equal:
- ...
- ... >>> print 1.1, 'intervening text', 1L # should match
- ... 1.1 intervening text 1L
- ... >>> print 1.0j, 22, 22.0, 1, 1e1 # should match
- ... 1j 22.0 22 1 10.0
- ...
- ... Numbers will match if they are equal to 14 digits of
- ... precision:
- ...
- ... >>> 2.00000000001 # should match
- ... 1.99999999999
- ... >>> 2.000000001 # should not match
- ... 1.999999999
- ... >>> 2.00000000001e10 # should match
- ... 1.99999999999e10
- ... >>> 2.000000001e10 # should not match
- ... 1.999999999e10
- ... '''
-
- >>> # Without the flag:
- >>> test = doctest.DocTestFinder().find(f)[0]
- >>> doctest.DocTestRunner(verbose=False).run(test)
- ... # doctest: +ELLIPSIS
- **********************************************************************
- File ..., line 4, in f
- Failed example:
- print 1.1, 'intervening text', 1L # should match
- Expected:
- 1.1 intervening text 1L
- Got:
- 1.1 intervening text 1
- **********************************************************************
- File ..., line 6, in f
- Failed example:
- print 1.0j, 22, 22.0, 1, 1e1 # should match
- Expected:
- 1j 22.0 22 1 10.0
- Got:
- 1j 22 22.0 1 10.0
- **********************************************************************
- File ..., line 12, in f
- Failed example:
- 2.00000000001 # should match
- Expected:
- 1.99999999999
- Got:
- 2.00000000001
- **********************************************************************
- File ..., line 14, in f
- Failed example:
- 2.000000001 # should not match
- Expected:
- 1.999999999
- Got:
- 2.0000000010000001
- **********************************************************************
- File ..., line 16, in f
- Failed example:
- 2.00000000001e10 # should match
- Expected:
- 1.99999999999e10
- Got:
- 20000000000.099998
- **********************************************************************
- File ..., line 18, in f
- Failed example:
- 2.000000001e10 # should not match
- Expected:
- 1.999999999e10
- Got:
- 20000000010.0
- (6, 6)
-
- >>> # With the flag:
- >>> test = doctest.DocTestFinder().find(f)[0]
- >>> flags = doctest.NORMALIZE_NUMBERS
- >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
- ... # doctest: +ELLIPSIS
- **********************************************************************
- File ..., line 14, in f
- Failed example:
- 2.000000001 # should not match
- Expected:
- 1.999999999
- Got:
- 2.0000000010000001
- **********************************************************************
- File ..., line 18, in f
- Failed example:
- 2.000000001e10 # should not match
- Expected:
- 1.999999999e10
- Got:
- 20000000010.0
- (2, 6)
-
The ELLIPSIS flag causes ellipsis marker ("...") in the expected
output to match any substring in the actual output: