summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-08-18 14:48:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-08-18 14:48:15 (GMT)
commit79c27c331927e0354f335362010ff86ba1855280 (patch)
treee62eef901aa9b46cd40e47c3e400450e3e27329d
parentc5847414f9e46ccac42689196e5656b1be0dc957 (diff)
parentd6ec309c368d300913f776b8d19e35224c7a44b7 (diff)
downloadcpython-79c27c331927e0354f335362010ff86ba1855280.zip
cpython-79c27c331927e0354f335362010ff86ba1855280.tar.gz
cpython-79c27c331927e0354f335362010ff86ba1855280.tar.bz2
Clean up test_user_command.
-rw-r--r--Lib/test/test_tcl.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index 79fb96be5..5ab2877 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -427,28 +427,31 @@ class TclTest(unittest.TestCase):
return arg
self.interp.createcommand('testfunc', testfunc)
self.addCleanup(self.interp.tk.deletecommand, 'testfunc')
- def check(value, expected, eq=self.assertEqual):
+ def check(value, expected=None, *, eq=self.assertEqual):
+ if expected is None:
+ expected = value
+ nonlocal result
+ result = None
r = self.interp.call('testfunc', value)
self.assertIsInstance(result, str)
eq(result, expected)
self.assertIsInstance(r, str)
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\u20ac', 'string\u20ac')
+ check('string')
+ check('string\xbd')
+ check('string\u20ac')
check(b'string', 'string')
check(b'string\xe2\x82\xac', 'string\xe2\x82\xac')
check(b'string\xbd', 'string\xbd')
- check('str\x00ing', 'str\x00ing')
- check('str\x00ing\xbd', 'str\x00ing\xbd')
- check('str\x00ing\u20ac', 'str\x00ing\u20ac')
+ check('str\x00ing')
+ check('str\x00ing\xbd')
+ check('str\x00ing\u20ac')
check(b'str\x00ing', 'str\x00ing')
check(b'str\xc0\x80ing', 'str\xc0\x80ing')
check(b'str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac')
@@ -458,9 +461,9 @@ class TclTest(unittest.TestCase):
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} {}')