summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-08-18 14:46:34 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-08-18 14:46:34 (GMT)
commitede745a7edb9ada7fba7cee07d60f2a8ee9d924f (patch)
treee8991f8e33eacfc24990dfd36a896149c8b232f4 /Lib
parent44ae51347c7b4eba98e6593a8c6539f7a4a870ab (diff)
downloadcpython-ede745a7edb9ada7fba7cee07d60f2a8ee9d924f.zip
cpython-ede745a7edb9ada7fba7cee07d60f2a8ee9d924f.tar.gz
cpython-ede745a7edb9ada7fba7cee07d60f2a8ee9d924f.tar.bz2
Clean up test_user_command.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_tcl.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index fcbafc5..c0afba6 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -434,43 +434,42 @@ class TclTest(unittest.TestCase):
return arg
self.interp.createcommand('testfunc', testfunc)
self.addCleanup(self.interp.tk.deletecommand, 'testfunc')
- def check(value, expected, expected2=None, eq=self.assertEqual):
- if expected2 is None:
- expected2 = expected
+ def check(value, expected=None, eq=self.assertEqual):
+ if expected is None:
+ expected = value
del result[:]
r = self.interp.call('testfunc', value)
self.assertEqual(len(result), 1)
self.assertIsInstance(result[0], (str, unicode))
- eq(result[0], expected2)
+ eq(result[0], expected)
self.assertIsInstance(r, (str, unicode))
- eq(r, expected2)
+ eq(r, expected)
def float_eq(actual, expected):
- expected = float(expected)
self.assertAlmostEqual(float(actual), expected,
delta=abs(expected) * 1e-10)
check(True, '1')
check(False, '0')
- check('string', 'string')
- check('string\xbd', 'string\xbd')
- check('string\xe2\x82\xac', 'string\xe2\x82\xac', u'string\u20ac')
- check(u'string', u'string')
- check(u'string\xbd', 'string\xc2\xbd', u'string\xbd')
- check(u'string\u20ac', 'string\xe2\x82\xac', u'string\u20ac')
- check('str\xc0\x80ing', 'str\xc0\x80ing', u'str\x00ing')
- check('str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac', u'str\x00ing\u20ac')
- check(u'str\x00ing', 'str\xc0\x80ing', u'str\x00ing')
- check(u'str\x00ing\xbd', 'str\xc0\x80ing\xc2\xbd', u'str\x00ing\xbd')
- check(u'str\x00ing\u20ac', 'str\xc0\x80ing\xe2\x82\xac', u'str\x00ing\u20ac')
+ check('string')
+ check('string\xbd')
+ check('string\xe2\x82\xac', u'string\u20ac')
+ check(u'string')
+ check(u'string\xbd')
+ check(u'string\u20ac')
+ check('str\xc0\x80ing', u'str\x00ing')
+ check('str\xc0\x80ing\xe2\x82\xac', u'str\x00ing\u20ac')
+ check(u'str\x00ing')
+ check(u'str\x00ing\xbd')
+ check(u'str\x00ing\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):
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, eq=float_eq)
- check(float('inf'), 'Inf', eq=float_eq)
- check(-float('inf'), '-Inf', eq=float_eq)
+ check(f, eq=float_eq)
+ check(float('inf'), eq=float_eq)
+ check(-float('inf'), eq=float_eq)
# XXX NaN representation can be not parsable by float()
check((), '')
check((1, (2,), (3, 4), '5 6', ()), '1 2 {3 4} {5 6} {}')