[Python-checkins] cpython (2.7): Clean up test_user_command.

serhiy.storchaka python-checkins at python.org
Mon Aug 18 16:49:42 CEST 2014


http://hg.python.org/cpython/rev/5c54f3818efd
changeset:   92147:5c54f3818efd
branch:      2.7
parent:      92133:0b79c702abda
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Aug 18 17:46:34 2014 +0300
summary:
  Clean up test_user_command.

files:
  Lib/test/test_tcl.py |  39 +++++++++++++++----------------
  1 files changed, 19 insertions(+), 20 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
@@ -434,43 +434,42 @@
             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} {}')

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list