Other attempt to fix test_user_command on OpenSolaris.
This commit is contained in:
parent
83515ecf42
commit
dc97667254
|
@ -210,14 +210,19 @@ class TclTest(unittest.TestCase):
|
|||
result.append(arg)
|
||||
return arg
|
||||
self.interp.createcommand('testfunc', testfunc)
|
||||
def check(value, expected, conv=lambda x: x):
|
||||
def check(value, expected, eq=self.assertEqual):
|
||||
del result[:]
|
||||
r = self.interp.call('testfunc', value)
|
||||
self.assertEqual(len(result), 1)
|
||||
self.assertIsInstance(result[0], str)
|
||||
self.assertEqual(conv(result[0]), expected)
|
||||
eq(result[0], expected)
|
||||
self.assertIsInstance(r, str)
|
||||
self.assertEqual(conv(r), expected)
|
||||
eq(r, expected)
|
||||
def float_eq(actual, expected):
|
||||
self.assertAlmostEqual(float(actual), float(expected))
|
||||
def nan_eq(actual, expected):
|
||||
actual = float(actual)
|
||||
self.assertNotEqual(actual, actual)
|
||||
|
||||
check(True, '1')
|
||||
check(False, '0')
|
||||
|
@ -226,13 +231,14 @@ class TclTest(unittest.TestCase):
|
|||
check('string\u20ac', 'string\u20ac')
|
||||
for i in (0, 1, -1, 2**31-1, -2**31):
|
||||
check(i, str(i))
|
||||
for f in (0.0, 1.0, -1.0, 1/3,
|
||||
sys.float_info.min, sys.float_info.max,
|
||||
for f in (0.0, 1.0, -1.0):
|
||||
check(f, repr(f))
|
||||
for f in (1/3.0, sys.float_info.min, sys.float_info.max,
|
||||
-sys.float_info.min, -sys.float_info.max):
|
||||
check(f, f, conv=float)
|
||||
check(float('inf'), float('inf'), conv=float)
|
||||
check(-float('inf'), -float('inf'), conv=float)
|
||||
check(float('nan'), 'NaN')
|
||||
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((), '')
|
||||
check((1, (2,), (3, 4), '5 6', ()), '1 2 {3 4} {5 6} {}')
|
||||
|
||||
|
|
Loading…
Reference in New Issue