Syntax cleanup.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Wed, 28 Jul 2010 16:39:41 +0000 (16:39 +0000)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Wed, 28 Jul 2010 16:39:41 +0000 (16:39 +0000)
Lib/ctypes/test/test_callbacks.py
Lib/json/encoder.py
Lib/pickletools.py
Lib/test/script_helper.py
Lib/test/test_binop.py
Lib/test/test_pow.py
Lib/test/test_sys.py

index ea51c336106ca559f5c17823bbf5a27b1d14553e..36fc539bdbefa1cd9b2902b1fa4b8bc686790c21 100644 (file)
@@ -164,7 +164,7 @@ class SampleCallbacksTestCase(unittest.TestCase):
         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
index 2beb10e358bd61ad54cf7613a4afb31cbbcc4054..d068e722165777a8d4fd8ed83084d9f9de8aa81d 100644 (file)
@@ -397,7 +397,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
             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)
index e067d7eb0162642c1607c476737abf08ca6f7bf7..89a8e5845a365dc1c617dfb83695d20a8ccc46b1 100644 (file)
@@ -733,7 +733,7 @@ pylong = StackObject(
 
 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.")
 
index 39874d97ece49fcd9620d7bb7889d62bcc1fdb75..28d5e9d13bef34514d64df7d95044e356a272839 100644 (file)
@@ -79,7 +79,7 @@ def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
             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 @@ def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
     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()
index 5f3ba8b402b98455d0e6465e63afcc876a8a483c..84179167e21801ed9af323bb94d75267da5d3b3f 100644 (file)
@@ -16,7 +16,7 @@ def isint(x):
 
 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
index 859c3737b9097322ffea755e21a64fa6687ef967..60bb5330eb3e34663113655776203cb7cafb814f 100644 (file)
@@ -18,14 +18,14 @@ class PowTest(unittest.TestCase):
                 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)
index 9389254b7a073420ed236d99310c5e7048ef84a0..eb5d877283a50f509977d410f79b59981cb31e72 100644 (file)
@@ -86,7 +86,6 @@ class SysModuleTest(unittest.TestCase):
     # Python/pythonrun.c::PyErr_PrintEx() is tricky.
 
     def test_exit(self):
-        import subprocess
 
         self.assertRaises(TypeError, sys.exit, 42, 42)
 
@@ -529,7 +528,6 @@ class SysModuleTest(unittest.TestCase):
         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 @@ class SysModuleTest(unittest.TestCase):
         # 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))