[Python-checkins] cpython (merge 3.4 -> default): Issue #21881: Be more tolerant in test_tcl to not parsable by float() NaN
serhiy.storchaka
python-checkins at python.org
Mon Jul 7 12:48:33 CEST 2014
http://hg.python.org/cpython/rev/72289f574664
changeset: 91570:72289f574664
parent: 91567:fc7f28b11d20
parent: 91569:4879f6337ef6
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Jul 07 13:45:15 2014 +0300
summary:
Issue #21881: Be more tolerant in test_tcl to not parsable by float() NaN
representations (on mips and m68k platforms).
files:
Lib/test/test_tcl.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -406,8 +406,9 @@
self.assertEqual(passValue(float('inf')), float('inf'))
self.assertEqual(passValue(-float('inf')), -float('inf'))
else:
- f = float(passValue(float('nan')))
- self.assertNotEqual(f, f)
+ f = passValue(float('nan'))
+ self.assertIsInstance(f, str)
+ self.assertEqual(f.lower()[:3], 'nan')
self.assertEqual(float(passValue(float('inf'))), float('inf'))
self.assertEqual(float(passValue(-float('inf'))), -float('inf'))
self.assertEqual(passValue((1, '2', (3.4,))),
@@ -433,9 +434,8 @@
expected = float(expected)
self.assertAlmostEqual(float(actual), expected,
delta=abs(expected) * 1e-10)
- def nan_eq(actual, expected):
- actual = float(actual)
- self.assertNotEqual(actual, actual)
+ def starts_with(actual, expected):
+ self.assertEqual(actual.lower()[:len(expected)], expected)
check(True, '1')
check(False, '0')
@@ -458,7 +458,7 @@
check(f, f, eq=float_eq)
check(float('inf'), 'Inf', eq=float_eq)
check(-float('inf'), '-Inf', eq=float_eq)
- check(float('nan'), 'NaN', eq=nan_eq)
+ check(float('nan'), 'nan', eq=starts_with)
check((), '')
check((1, (2,), (3, 4), '5 6', ()), '1 2 {3 4} {5 6} {}')
check([1, [2,], [3, 4], '5 6', []], '1 2 {3 4} {5 6} {}')
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list