[Python-checkins] r83212 - in python/branches/py3k/Lib: ctypes/test/test_callbacks.py json/encoder.py pickletools.py test/script_helper.py test/test_binop.py test/test_pow.py test/test_sys.py

florent.xicluna python-checkins at python.org
Wed Jul 28 18:39:41 CEST 2010


Author: florent.xicluna
Date: Wed Jul 28 18:39:41 2010
New Revision: 83212

Log:
Syntax cleanup.


Modified:
   python/branches/py3k/Lib/ctypes/test/test_callbacks.py
   python/branches/py3k/Lib/json/encoder.py
   python/branches/py3k/Lib/pickletools.py
   python/branches/py3k/Lib/test/script_helper.py
   python/branches/py3k/Lib/test/test_binop.py
   python/branches/py3k/Lib/test/test_pow.py
   python/branches/py3k/Lib/test/test_sys.py

Modified: python/branches/py3k/Lib/ctypes/test/test_callbacks.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_callbacks.py	(original)
+++ python/branches/py3k/Lib/ctypes/test/test_callbacks.py	Wed Jul 28 18:39:41 2010
@@ -164,7 +164,7 @@
         result = integrate(0.0, 1.0, CALLBACK(func), 10)
         diff = abs(result - 1./3.)
 
-        self.assertTrue(diff < 0.01, "%s not less than 0.01" % diff)
+        self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
 
     def test_issue_8959_a(self):
         from ctypes.util import find_library

Modified: python/branches/py3k/Lib/json/encoder.py
==============================================================================
--- python/branches/py3k/Lib/json/encoder.py	(original)
+++ python/branches/py3k/Lib/json/encoder.py	Wed Jul 28 18:39:41 2010
@@ -397,7 +397,7 @@
             yield 'true'
         elif o is False:
             yield 'false'
-        elif isinstance(o, (int, int)):
+        elif isinstance(o, int):
             yield str(o)
         elif isinstance(o, float):
             yield _floatstr(o)

Modified: python/branches/py3k/Lib/pickletools.py
==============================================================================
--- python/branches/py3k/Lib/pickletools.py	(original)
+++ python/branches/py3k/Lib/pickletools.py	Wed Jul 28 18:39:41 2010
@@ -733,7 +733,7 @@
 
 pyinteger_or_bool = StackObject(
                         name='int_or_bool',
-                        obtype=(int, int, bool),
+                        obtype=(int, bool),
                         doc="A Python integer object (short or long), or "
                             "a Python bool.")
 

Modified: python/branches/py3k/Lib/test/script_helper.py
==============================================================================
--- python/branches/py3k/Lib/test/script_helper.py	(original)
+++ python/branches/py3k/Lib/test/script_helper.py	Wed Jul 28 18:39:41 2010
@@ -79,7 +79,7 @@
             name_in_zip = os.path.basename(script_name)
     zip_file.write(script_name, name_in_zip)
     zip_file.close()
-    #if test.test_support.verbose:
+    #if test.support.verbose:
     #    zip_file = zipfile.ZipFile(zip_name, 'r')
     #    print 'Contents of %r:' % zip_name
     #    zip_file.printdir()
@@ -114,7 +114,7 @@
     zip_file.close()
     for name in unlink:
         os.unlink(name)
-    #if test.test_support.verbose:
+    #if test.support.verbose:
     #    zip_file = zipfile.ZipFile(zip_name, 'r')
     #    print 'Contents of %r:' % zip_name
     #    zip_file.printdir()

Modified: python/branches/py3k/Lib/test/test_binop.py
==============================================================================
--- python/branches/py3k/Lib/test/test_binop.py	(original)
+++ python/branches/py3k/Lib/test/test_binop.py	Wed Jul 28 18:39:41 2010
@@ -16,7 +16,7 @@
 
 def isnum(x):
     """Test whether an object is an instance of a built-in numeric type."""
-    for T in int, int, float, complex:
+    for T in int, float, complex:
         if isinstance(x, T):
             return 1
     return 0

Modified: python/branches/py3k/Lib/test/test_pow.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pow.py	(original)
+++ python/branches/py3k/Lib/test/test_pow.py	Wed Jul 28 18:39:41 2010
@@ -18,14 +18,14 @@
                 self.assertEquals(pow(2, i), pow2)
                 if i != 30 : pow2 = pow2*2
 
-            for othertype in int, int:
+            for othertype in (int,):
                 for i in list(range(-10, 0)) + list(range(1, 10)):
                     ii = type(i)
                     for j in range(1, 11):
                         jj = -othertype(j)
                         pow(ii, jj)
 
-        for othertype in int, int, float:
+        for othertype in int, float:
             for i in range(1, 100):
                 zero = type(0)
                 exp = -othertype(i/10.0)

Modified: python/branches/py3k/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k/Lib/test/test_sys.py	(original)
+++ python/branches/py3k/Lib/test/test_sys.py	Wed Jul 28 18:39:41 2010
@@ -86,7 +86,6 @@
     # Python/pythonrun.c::PyErr_PrintEx() is tricky.
 
     def test_exit(self):
-        import subprocess
 
         self.assertRaises(TypeError, sys.exit, 42, 42)
 
@@ -529,7 +528,6 @@
         sys._clear_type_cache()
 
     def test_ioencoding(self):
-        import subprocess
         env = dict(os.environ)
 
         # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424,
@@ -551,7 +549,7 @@
         # Issue #7774: Ensure that sys.executable is an empty string if argv[0]
         # has been set to an non existent program name and Python is unable to
         # retrieve the real program name
-        import subprocess
+
         # For a normal installation, it should work without 'cwd'
         # argument. For test runs in the build directory, see #7774.
         python_dir = os.path.dirname(os.path.realpath(sys.executable))


More information about the Python-checkins mailing list