[Python-checkins] cpython (2.7): Try to fix test_user_command on OpenSolaris where floats can have different
serhiy.storchaka
python-checkins at python.org
Thu Jan 23 10:04:02 CET 2014
http://hg.python.org/cpython/rev/5f91500b3b02
changeset: 88647:5f91500b3b02
branch: 2.7
parent: 88644:43f9295f6b99
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Jan 23 11:03:02 2014 +0200
summary:
Try to fix test_user_command on OpenSolaris where floats can have different
string representation in Tcl and Python.
files:
Lib/test/test_tcl.py | 16 ++++++++++------
1 files changed, 10 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
@@ -210,10 +210,14 @@
result.append(arg)
return arg
self.interp.createcommand('testfunc', testfunc)
- def check(value, expected):
+ def check(value, expected, conv=lambda x: x):
del result[:]
- self.assertEqual(self.interp.call('testfunc', value), expected)
- self.assertEqual(result, [expected])
+ r = self.interp.call('testfunc', value)
+ self.assertEqual(len(result), 1)
+ self.assertIsInstance(result[0], str)
+ self.assertEqual(conv(result[0]), expected)
+ self.assertIsInstance(r, str)
+ self.assertEqual(conv(r), expected)
check(True, '1')
check(False, '0')
@@ -225,10 +229,10 @@
for f in (0.0, 1.0, -1.0, 1/3,
sys.float_info.min, sys.float_info.max,
-sys.float_info.min, -sys.float_info.max):
- check(f, repr(f))
+ check(f, f, conv=float)
+ check(float('inf'), float('inf'), conv=float)
+ check(-float('inf'), -float('inf'), conv=float)
check(float('nan'), 'NaN')
- check(float('inf'), 'Inf')
- check(-float('inf'), '-Inf')
check((), '')
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