From: Serhiy Storchaka Date: Thu, 23 Jan 2014 09:03:02 +0000 (+0200) Subject: Try to fix test_user_command on OpenSolaris where floats can have different X-Git-Tag: v2.7.8~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=83515ecf42c13ccf3c53038ba05c45dcb1298c93;p=python Try to fix test_user_command on OpenSolaris where floats can have different string representation in Tcl and Python. --- diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index ba61c455fd..5863dd572c 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -210,10 +210,14 @@ class TclTest(unittest.TestCase): 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 @@ class TclTest(unittest.TestCase): 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} {}')