]> granicus.if.org Git - python/commitdiff
Merged revisions 78018,78035-78040,78042-78043,78046,78048-78052,78054,78059,78075...
authorGeorg Brandl <georg@python.org>
Sun, 14 Mar 2010 10:23:39 +0000 (10:23 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 14 Mar 2010 10:23:39 +0000 (10:23 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78018 | georg.brandl | 2010-02-06 11:08:21 +0100 (Sa, 06 Feb 2010) | 1 line

  #7864: make deprecation notices a bit clearer.
........
  r78035 | georg.brandl | 2010-02-06 23:44:17 +0100 (Sa, 06 Feb 2010) | 1 line

  Fix duplicate import.
........
  r78036 | georg.brandl | 2010-02-06 23:49:47 +0100 (Sa, 06 Feb 2010) | 1 line

  Remove unused import.
........
  r78037 | georg.brandl | 2010-02-06 23:59:15 +0100 (Sa, 06 Feb 2010) | 1 line

  No need to assign the results of expressions used only for side effects.
........
  r78038 | georg.brandl | 2010-02-07 00:02:29 +0100 (So, 07 Feb 2010) | 1 line

  Add a missing import.
........
  r78039 | georg.brandl | 2010-02-07 00:06:24 +0100 (So, 07 Feb 2010) | 1 line

  Add missing imports.
........
  r78040 | georg.brandl | 2010-02-07 00:08:00 +0100 (So, 07 Feb 2010) | 1 line

  Fix a few UnboundLocalErrors in test_long.
........
  r78042 | georg.brandl | 2010-02-07 00:12:12 +0100 (So, 07 Feb 2010) | 1 line

  Add missing import.
........
  r78043 | georg.brandl | 2010-02-07 00:12:19 +0100 (So, 07 Feb 2010) | 1 line

  Remove duplicate test method.
........
  r78046 | georg.brandl | 2010-02-07 00:18:00 +0100 (So, 07 Feb 2010) | 1 line

  Fix various missing import/unbound name errors.
........
  r78048 | georg.brandl | 2010-02-07 00:23:45 +0100 (So, 07 Feb 2010) | 1 line

  We heard you like test failures so we put unbound locals in your test so that you can fail while you fail.
........
  r78049 | georg.brandl | 2010-02-07 00:33:33 +0100 (So, 07 Feb 2010) | 1 line

  Fix import/access for some identifiers.  _TestSharedCTypes does not seem to be executed?
........
  r78050 | georg.brandl | 2010-02-07 00:34:10 +0100 (So, 07 Feb 2010) | 1 line

  Fix more unbound locals in code paths that do not seem to be used.
........
  r78051 | georg.brandl | 2010-02-07 00:53:52 +0100 (So, 07 Feb 2010) | 1 line

  Add missing import when running these tests standalone.
........
  r78052 | georg.brandl | 2010-02-07 00:54:04 +0100 (So, 07 Feb 2010) | 1 line

  Add missing import when running these tests standalone.
........
  r78054 | georg.brandl | 2010-02-07 00:58:25 +0100 (So, 07 Feb 2010) | 1 line

  Add missing import.
........
  r78059 | georg.brandl | 2010-02-07 12:34:15 +0100 (So, 07 Feb 2010) | 1 line

  Use "regexp" consistently.
........
  r78075 | georg.brandl | 2010-02-07 13:16:12 +0100 (So, 07 Feb 2010) | 1 line

  Fix another duplicated test method.
........
  r78076 | georg.brandl | 2010-02-07 13:19:43 +0100 (So, 07 Feb 2010) | 1 line

  Fix wrong usage of "except X, Y:".
........
  r78077 | georg.brandl | 2010-02-07 13:25:50 +0100 (So, 07 Feb 2010) | 1 line

  Fix two redefined test methods.
........
  r78078 | georg.brandl | 2010-02-07 13:27:06 +0100 (So, 07 Feb 2010) | 1 line

  Fix a redefined test method.
........
  r78079 | georg.brandl | 2010-02-07 13:34:26 +0100 (So, 07 Feb 2010) | 1 line

  Add a minimal test for fnmatchcase().
........
  r78080 | georg.brandl | 2010-02-07 13:55:12 +0100 (So, 07 Feb 2010) | 1 line

  Remove duplicate test method.
........

33 files changed:
Doc/library/unittest.rst
Lib/distutils/tests/test_bdist.py
Lib/distutils/tests/test_bdist_dumb.py
Lib/distutils/tests/test_bdist_msi.py
Lib/distutils/tests/test_bdist_rpm.py
Lib/distutils/tests/test_bdist_wininst.py
Lib/distutils/tests/test_cmd.py
Lib/distutils/tests/test_cygwinccompiler.py
Lib/distutils/tests/test_emxccompiler.py
Lib/distutils/tests/test_sysconfig.py
Lib/email/test/test_email_torture.py
Lib/genericpath.py
Lib/mimetypes.py
Lib/posixpath.py
Lib/subprocess.py
Lib/test/test_csv.py
Lib/test/test_docxmlrpc.py
Lib/test/test_fnmatch.py
Lib/test/test_functools.py
Lib/test/test_long.py
Lib/test/test_minidom.py
Lib/test/test_multiprocessing.py
Lib/test/test_optparse.py
Lib/test/test_pep292.py
Lib/test/test_platform.py
Lib/test/test_posixpath.py
Lib/test/test_richcmp.py
Lib/test/test_ssl.py
Lib/test/test_sysconfig.py
Lib/test/test_tempfile.py
Lib/test/test_threaded_import.py
Lib/test/test_zipimport.py
Lib/unittest/case.py

index a53fb8718a4d6130bdfd6d5ffcb1693392c3252f..e2272f7146621651e234501d61fed88bbeb3bdb0 100644 (file)
@@ -676,7 +676,7 @@ Test cases
       will be *msg* if given, otherwise it will be :const:`None`.
 
       .. deprecated:: 3.1
-         :meth:`failUnless`.
+         :meth:`failUnless`; use one of the ``assert`` variants.
          :meth:`assert_`; use :meth:`assertTrue`.
 
 
@@ -704,7 +704,7 @@ Test cases
          function for comparing strings.
 
       .. deprecated:: 3.1
-         :meth:`failUnlessEqual`.
+         :meth:`failUnlessEqual`; use :meth:`assertEqual`.
 
 
    .. method:: assertNotEqual(first, second, msg=None)
@@ -718,7 +718,7 @@ Test cases
       *first* and *second*.
 
       .. deprecated:: 3.1
-         :meth:`failIfEqual`.
+         :meth:`failIfEqual`; use :meth:`assertNotEqual`.
 
 
    .. method:: assertAlmostEqual(first, second, *, places=7, msg=None)
@@ -737,7 +737,7 @@ Test cases
          Objects that compare equal are automatically almost equal.
 
       .. deprecated:: 3.1
-         :meth:`failUnlessAlmostEqual`.
+         :meth:`failUnlessAlmostEqual`; use :meth:`assertAlmostEqual`.
 
 
    .. method:: assertNotAlmostEqual(first, second, *, places=7, msg=None)
@@ -756,7 +756,7 @@ Test cases
          Objects that compare equal automatically fail.
 
       .. deprecated:: 3.1
-         :meth:`failIfAlmostEqual`.
+         :meth:`failIfAlmostEqual`; use :meth:`assertNotAlmostEqual`.
 
 
    .. method:: assertGreater(first, second, msg=None)
@@ -923,7 +923,7 @@ Test cases
          Added the :attr:`exception` attribute.
 
       .. deprecated:: 3.1
-         :meth:`failUnlessRaises`.
+         :meth:`failUnlessRaises`; use :meth:`assertRaises`.
 
 
    .. method:: assertRaisesRegexp(exception, regexp[, callable, ...])
@@ -1000,7 +1000,7 @@ Test cases
       for the error message.
 
       .. deprecated:: 3.1
-         :meth:`failIf`.
+         :meth:`failIf`; use :meth:`assertFalse`.
 
 
    .. method:: fail(msg=None)
index f2849a9756a71bd187a258769efe59fc82fd5a0b..29dcc7c8ba9c8d703a8dcad394924f60154feab2 100644 (file)
@@ -5,6 +5,8 @@ import os
 import tempfile
 import shutil
 
+from test.support import run_unittest
+
 from distutils.core import Distribution
 from distutils.command.bdist import bdist
 from distutils.tests import support
@@ -40,4 +42,4 @@ def test_suite():
     return unittest.makeSuite(BuildTestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index 5eaef2a9d70229aacf253a1d9727dd0c889aac96..746144bf5bf8e9d029341ded2f18b2f544067aa5 100644 (file)
@@ -11,6 +11,8 @@ try:
 except ImportError:
     zlib = None
 
+from test.support import run_unittest
+
 from distutils.core import Distribution
 from distutils.command.bdist_dumb import bdist_dumb
 from distutils.tests import support
@@ -100,4 +102,4 @@ def test_suite():
     return unittest.makeSuite(BuildDumbTestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index ba2d3e19c2b2136ab77ecc5b94ca59fdad9623eb..2b2d8542ee015ffdacaa149b16014cfee34225f3 100644 (file)
@@ -2,6 +2,8 @@
 import unittest
 import sys
 
+from test.support import run_unittest
+
 from distutils.tests import support
 
 @unittest.skipUnless(sys.platform=="win32", "These tests are only for win32")
@@ -20,4 +22,4 @@ def test_suite():
     return unittest.makeSuite(BDistMSITestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index 2aa257f7e633bf9b62b2804f6c6f7c5a0cef4e3a..1014e549af8d808787b5439aa31936fb672ee8ef 100644 (file)
@@ -6,6 +6,8 @@ import os
 import tempfile
 import shutil
 
+from test.support import run_unittest
+
 from distutils.core import Distribution
 from distutils.command.bdist_rpm import bdist_rpm
 from distutils.tests import support
@@ -122,4 +124,4 @@ def test_suite():
     return unittest.makeSuite(BuildRpmTestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index 9b1ba6d1074138c7d05177368354e049d9ce0f1b..ffe413536c2d71aaec3a6c1a6acbd6208f2c74e2 100644 (file)
@@ -1,6 +1,8 @@
 """Tests for distutils.command.bdist_wininst."""
 import unittest
 
+from test.support import run_unittest
+
 from distutils.command.bdist_wininst import bdist_wininst
 from distutils.tests import support
 
@@ -27,4 +29,4 @@ def test_suite():
     return unittest.makeSuite(BuildWinInstTestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index 55ae421d460a2bdf6d4da4683056ba600c287b92..728652e2caa80ffca6e86aa95f2103ffff4e8138 100644 (file)
@@ -1,7 +1,7 @@
 """Tests for distutils.cmd."""
 import unittest
 import os
-from test.support import captured_stdout
+from test.support import captured_stdout, run_unittest
 
 from distutils.cmd import Command
 from distutils.dist import Distribution
@@ -124,4 +124,4 @@ def test_suite():
     return unittest.makeSuite(CommandTestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index 4b95dfa3aae7d184a68ab5c8fd7f05f441f6c4c6..374f392d6199b1b6f0124c1141bd4d56de5e44d9 100644 (file)
@@ -6,7 +6,7 @@ import subprocess
 import warnings
 import sysconfig
 
-from test.support import check_warnings
+from test.support import check_warnings, run_unittest
 from test.support import captured_stdout
 
 from distutils import cygwinccompiler
@@ -109,4 +109,4 @@ def test_suite():
     return unittest.makeSuite(CygwinCCompilerTestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index 2176d641d01257e5f434486edfb0b399766c72e3..1360f8297a6aeb6a7cd51ad0d3d6a6892c16b937 100644 (file)
@@ -4,7 +4,7 @@ import sys
 import os
 import warnings
 
-from test.support import check_warnings
+from test.support import check_warnings, run_unittest
 from test.support import captured_stdout
 
 from distutils.emxccompiler import get_versions
@@ -30,4 +30,4 @@ def test_suite():
     return unittest.makeSuite(EmxCCompilerTestCase)
 
 if __name__ == '__main__':
-    test_support.run_unittest(test_suite())
+    run_unittest(test_suite())
index e7df803168574fd5311146b878a4b1221f9d0e0e..9496950f70a16ec9e861b2ef9f26696892b16556 100644 (file)
@@ -2,6 +2,7 @@
 import os
 import test
 import unittest
+import shutil
 
 from distutils import sysconfig
 from distutils.tests import support
index 67d1a4775ee3b273c81dba116206fdeacb7642cd..544b1bbb39788b0df731dbc77ca510ba369c5291 100644 (file)
@@ -13,7 +13,7 @@ from io import StringIO
 from types import ListType
 
 from email.test.test_email import TestEmailBase
-from test.support import TestSkipped
+from test.support import TestSkipped, run_unittest
 
 import email
 from email import __file__ as testfile
@@ -128,7 +128,7 @@ def suite():
 
 def test_main():
     for testclass in _testclasses():
-        support.run_unittest(testclass)
+        run_unittest(testclass)
 
 
 \f
index 41ad234829f909ae44e73263884be53de686b016..2174187a03a9c25ddaee3d822dee9d1a8057a2ec 100644 (file)
@@ -15,7 +15,7 @@ __all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime',
 def exists(path):
     """Test whether a path exists.  Returns False for broken symbolic links"""
     try:
-        st = os.stat(path)
+        os.stat(path)
     except os.error:
         return False
     return True
index f63a733e879c1f2dffb1e3e28f3040be6dabe54e..3c9883c917ed1a0d6234a7cdffa423a480ebf1fa 100644 (file)
@@ -538,7 +538,6 @@ _default_mime_types()
 
 
 if __name__ == '__main__':
-    import sys
     import getopt
 
     USAGE = """\
index aace2b203d31f50fe88c65795b47fcb410a0c250..5783975e4ac9a5dddb6dbbf2f401c9a0b85a12e3 100644 (file)
@@ -158,7 +158,7 @@ def islink(path):
 def lexists(path):
     """Test whether a path exists.  Returns True for broken symbolic links"""
     try:
-        st = os.lstat(path)
+        os.lstat(path)
     except os.error:
         return False
     return True
index b33601a5933be93dd02c7a46410ee4e697251915..b6afdeca563734c4c0673ac58bc2dab435974c44 100644 (file)
@@ -930,7 +930,7 @@ class Popen(object):
             """Wait for child process to terminate.  Returns returncode
             attribute."""
             if self.returncode is None:
-                obj = WaitForSingleObject(self._handle, INFINITE)
+                WaitForSingleObject(self._handle, INFINITE)
                 self.returncode = GetExitCodeProcess(self._handle)
             return self.returncode
 
index 2c4b78305dfd75d7f9851bf5fb89e86447ce9874..ca67ac6ee0f63e5cdfb2b753d9a05bfcedc6ffe8 100644 (file)
@@ -488,10 +488,10 @@ hammer and saw"
     def test_null(self):
         self.writerAssertEqual([], '')
 
-    def test_single(self):
+    def test_single_writer(self):
         self.writerAssertEqual([['abc']], 'abc\r\n')
 
-    def test_simple(self):
+    def test_simple_writer(self):
         self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n')
 
     def test_quotes(self):
index 5306c31d713e36593caf3542e367bcee7fc17c32..112be4643b6f4689e06d7dfd3024efd46e1d86bf 100644 (file)
@@ -4,6 +4,7 @@ import sys
 from test import support
 import threading
 import time
+import socket
 import unittest
 
 PORT = None
index 506c67999c5d0656f1bc413c13b198eac0a98fe7..2b510995796f1e4507a4767264b428879253fd11 100644 (file)
@@ -50,6 +50,11 @@ class FnmatchTestCase(unittest.TestCase):
         self.assertRaises(TypeError, fnmatchcase, 'test', b'*')
         self.assertRaises(TypeError, fnmatchcase, b'test', '*')
 
+    def test_fnmatchcase(self):
+        check = self.check_match
+        check('AbC', 'abc', 0)
+        check('abc', 'AbC', 0)
+
     def test_bytes(self):
         self.check_match(b'test', b'te*')
         self.check_match(b'test\xff', b'te*\xff')
index df335e8614a8f6d5223aa03b55ad7772224c852d..ae47dae95d826f2d666e08afe610aa6a8843ac04 100644 (file)
@@ -45,9 +45,17 @@ class TestPartial(unittest.TestCase):
         # attributes should not be writable
         if not isinstance(self.thetype, type):
             return
-        self.assertRaises(TypeError, setattr, p, 'func', map)
-        self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
-        self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))
+        self.assertRaises(AttributeError, setattr, p, 'func', map)
+        self.assertRaises(AttributeError, setattr, p, 'args', (1, 2))
+        self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2))
+
+        p = self.thetype(hex)
+        try:
+            del p.__dict__
+        except TypeError:
+            pass
+        else:
+            self.fail('partial object allowed __dict__ to be deleted')
 
     def test_argument_checking(self):
         self.assertRaises(TypeError, self.thetype)     # need at least a func arg
@@ -123,15 +131,6 @@ class TestPartial(unittest.TestCase):
         self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0)
         self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1)
 
-    def test_attributes(self):
-        p = self.thetype(hex)
-        try:
-            del p.__dict__
-        except TypeError:
-            pass
-        else:
-            self.fail('partial object allowed __dict__ to be deleted')
-
     def test_weakref(self):
         f = self.thetype(int, base=16)
         p = proxy(f)
index b4ab74f084757ce151bfa3a278c81ad35940d392..3c6b2159a0c559742ce88ce9ac0b0d687b77262e 100644 (file)
@@ -502,7 +502,7 @@ class LongTest(unittest.TestCase):
                     self.d = d
                     assert float(n) / float(d) == value
                 else:
-                    raise TypeError("can't deal with %r" % val)
+                    raise TypeError("can't deal with %r" % value)
 
             def _cmp__(self, other):
                 if not isinstance(other, Rat):
index 606fada99da6cc6082d3cd86ba67f346941c46ca..bd20fa14c35d65988471d837075444959fa1d9c8 100644 (file)
@@ -1449,12 +1449,13 @@ class MinidomTest(unittest.TestCase):
                 self.confirm(len(n1.entities) == len(n2.entities)
                         and len(n1.notations) == len(n2.notations))
                 for i in range(len(n1.notations)):
+                    # XXX this loop body doesn't seem to be executed?
                     no1 = n1.notations.item(i)
                     no2 = n1.notations.item(i)
                     self.confirm(no1.name == no2.name
                             and no1.publicId == no2.publicId
                             and no1.systemId == no2.systemId)
-                    statck.append((no1, no2))
+                    stack.append((no1, no2))
                 for i in range(len(n1.entities)):
                     e1 = n1.entities.item(i)
                     e2 = n2.entities.item(i)
index 452e1928301301536a1740bbcd25d73f8567b169..035860bd9615b5e84882bab5fa0b01670958cfb6 100644 (file)
@@ -1600,10 +1600,10 @@ class _TestSharedCTypes(BaseTestCase):
             return
 
         x = Value('i', 7, lock=lock)
-        y = Value(ctypes.c_double, 1.0/3.0, lock=lock)
+        y = Value(c_double, 1.0/3.0, lock=lock)
         foo = Value(_Foo, 3, 2, lock=lock)
-        arr = Array('d', list(range(10)), lock=lock)
-        string = Array('c', 20, lock=lock)
+        arr = self.Array('d', list(range(10)), lock=lock)
+        string = self.Array('c', 20, lock=lock)
         string.value = 'hello'
 
         p = self.Process(target=self._double, args=(x, y, foo, arr, string))
index ac33d6188380697a4ff7391464b2ff3844eb1b67..e9cc2decd12ce58897080776d9ca3ffb39fefdaa 100644 (file)
@@ -441,7 +441,7 @@ def _check_duration(option, opt, value):
             return int(value)
         else:
             return int(value[:-1]) * _time_units[value[-1]]
-    except ValueError as IndexError:
+    except (ValueError, IndexError):
         raise OptionValueError(
             'option %s: invalid duration: %r' % (opt, value))
 
index ce9b66363b76663f1c0d320a10aeee6ebd35c432..8537b25616e80873c280de8d2a676626ea756cd0 100644 (file)
@@ -86,13 +86,6 @@ class TestTemplate(unittest.TestCase):
         s = Template('$who likes $100')
         raises(ValueError, s.substitute, dict(who='tim'))
 
-    def test_delimiter_override(self):
-        class PieDelims(Template):
-            delimiter = '@'
-        s = PieDelims('@who likes to eat a bag of @{what} worth $100')
-        self.assertEqual(s.substitute(dict(who='tim', what='ham')),
-                         'tim likes to eat a bag of ham worth $100')
-
     def test_idpattern_override(self):
         class PathPattern(Template):
             idpattern = r'[_a-z][._a-z0-9]*'
@@ -183,6 +176,12 @@ class TestTemplate(unittest.TestCase):
         raises(ValueError, s.substitute, dict(gift='bud', who='you'))
         eq(s.safe_substitute(), 'this &gift is for &{who} &')
 
+        class PieDelims(Template):
+            delimiter = '@'
+        s = PieDelims('@who likes to eat a bag of @{what} worth $100')
+        self.assertEqual(s.substitute(dict(who='tim', what='ham')),
+                         'tim likes to eat a bag of ham worth $100')
+
 
 def test_main():
     from test import support
index af37185686256a827b2d488e6251fa0da838bdd6..98751624db32743e303e431deb8191dc45380581 100644 (file)
@@ -175,8 +175,10 @@ class PlatformTest(unittest.TestCase):
         if os.path.isdir(sys.executable) and \
            os.path.exists(sys.executable+'.exe'):
             # Cygwin horror
-            executable = executable + '.exe'
-        res = platform.libc_ver(sys.executable)
+            executable = sys.executable + '.exe'
+        else:
+            executable = sys.executable
+        res = platform.libc_ver(executable)
 
     def test_parse_release_file(self):
 
index be0afd0a5fe4c7ee925bace11d2f8f297d4212d0..7ba95f712d944b686ee62a94fea578512086cb55 100644 (file)
@@ -2,7 +2,7 @@ import unittest
 from test import support, test_genericpath
 
 import posixpath, os
-from posixpath import realpath, abspath, join, dirname, basename, relpath
+from posixpath import realpath, abspath, dirname, basename
 
 # An absolute path to a temporary filename for testing. We can't rely on TESTFN
 # being an absolute path, so we need this.
index aec8bf33278dca1ca0a31f7958205e7e790a4821..f8f3717b641e1cae8edfd57259ff63d050e26153 100644 (file)
@@ -192,12 +192,12 @@ class MiscTest(unittest.TestCase):
 
     def test_misbehavin(self):
         class Misb:
-            def __lt__(self, other): return 0
-            def __gt__(self, other): return 0
-            def __eq__(self, other): return 0
-            def __le__(self, other): raise TestFailed("This shouldn't happen")
-            def __ge__(self, other): raise TestFailed("This shouldn't happen")
-            def __ne__(self, other): raise TestFailed("This shouldn't happen")
+            def __lt__(self_, other): return 0
+            def __gt__(self_, other): return 0
+            def __eq__(self_, other): return 0
+            def __le__(self_, other): self.fail("This shouldn't happen")
+            def __ge__(self_, other): self.fail("This shouldn't happen")
+            def __ne__(self_, other): self.fail("This shouldn't happen")
         a = Misb()
         b = Misb()
         self.assertEqual(a<b, 0)
index 383c78a95ab18ca634abf4eeeb1ccc156e4e4c4c..3467e3a11b215ffdd84015d263851c7bdeb45e1d 100644 (file)
@@ -1063,9 +1063,9 @@ else:
                                     ssl_version=ssl.PROTOCOL_TLSv1)
                 s.connect((HOST, server.port))
             except ssl.SSLError as x:
-                raise support.TestFailed("Unexpected SSL error:  " + str(x))
+                self.fail("Unexpected SSL error:  " + str(x))
             except Exception as x:
-                raise support.TestFailed("Unexpected exception:  " + str(x))
+                self.fail("Unexpected exception:  " + str(x))
             else:
                 # helper methods for standardising recv* method signatures
                 def _recv_into():
@@ -1099,7 +1099,7 @@ else:
                         outdata = s.read()
                         outdata = str(outdata, 'ASCII', 'strict')
                         if outdata != indata.lower():
-                            raise support.TestFailed(
+                            self.fail(
                                 "While sending with <<{name:s}>> bad data "
                                 "<<{outdata:s}>> ({nout:d}) received; "
                                 "expected <<{indata:s}>> ({nin:d})\n".format(
@@ -1110,12 +1110,12 @@ else:
                             )
                     except ValueError as e:
                         if expect_success:
-                            raise support.TestFailed(
+                            self.fail(
                                 "Failed to send with method <<{name:s}>>; "
                                 "expected to succeed.\n".format(name=meth_name)
                             )
                         if not str(e).startswith(meth_name):
-                            raise support.TestFailed(
+                            self.fail(
                                 "Method <<{name:s}>> failed with unexpected "
                                 "exception message: {exp:s}\n".format(
                                     name=meth_name, exp=e
@@ -1129,7 +1129,7 @@ else:
                         outdata = recv_meth(*args)
                         outdata = str(outdata, 'ASCII', 'strict')
                         if outdata != indata.lower():
-                            raise support.TestFailed(
+                            self.fail(
                                 "While receiving with <<{name:s}>> bad data "
                                 "<<{outdata:s}>> ({nout:d}) received; "
                                 "expected <<{indata:s}>> ({nin:d})\n".format(
@@ -1140,12 +1140,12 @@ else:
                             )
                     except ValueError as e:
                         if expect_success:
-                            raise support.TestFailed(
+                            self.fail(
                                 "Failed to receive with method <<{name:s}>>; "
                                 "expected to succeed.\n".format(name=meth_name)
                             )
                         if not str(e).startswith(meth_name):
-                            raise support.TestFailed(
+                            self.fail(
                                 "Method <<{name:s}>> failed with unexpected "
                                 "exception message: {exp:s}\n".format(
                                     name=meth_name, exp=e
index 67057bcbefddf9d2def74bad91317d6cfa6ee3eb..614dffcaf3b55b630c95e86a9dd369a0357e35a3 100644 (file)
@@ -9,6 +9,7 @@ import sys
 import test
 import os
 import subprocess
+import shutil
 from copy import copy, deepcopy
 
 from test.support import run_unittest, TESTFN, unlink, get_attribute
index de65158b06c971e6cd539d6e5e82595c5c7ab4f6..5b6a42091e914957429687a19e883862dfb46b65 100644 (file)
@@ -127,7 +127,7 @@ class test__RandomNameSequence(TC):
                 if i == 20:
                     break
         except:
-            failOnException("iteration")
+            self.failOnException("iteration")
 
 test_classes.append(test__RandomNameSequence)
 
index af9e89dd3a8e21ff60c63f54e14cfda82d8a057e..29eab1a7b1dfbe30c0850bab9c2256900dccb1cb 100644 (file)
@@ -6,6 +6,7 @@
 # randrange, and then Python hangs.
 
 import _thread as thread
+import unittest
 from test.support import verbose, TestFailed
 
 critical_section = thread.allocate_lock()
index 02339346d230d7ef4aec18b24b8f300b88711e10..c89aef5799f099d1ad1d6a4eecf9aed9f12710fa 100644 (file)
@@ -227,7 +227,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
 
             mod_path = packdir2 + TESTMOD
             mod_name = module_path_to_dotted_name(mod_path)
-            pkg = __import__(mod_name)
+            __import__(mod_name)
             mod = sys.modules[mod_name]
             self.assertEquals(zi.get_source(TESTPACK), None)
             self.assertEquals(zi.get_source(mod_path), None)
@@ -271,7 +271,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
 
             mod_path = TESTPACK2 + os.sep + TESTMOD
             mod_name = module_path_to_dotted_name(mod_path)
-            pkg = __import__(mod_name)
+            __import__(mod_name)
             mod = sys.modules[mod_name]
             self.assertEquals(zi.get_source(TESTPACK2), None)
             self.assertEquals(zi.get_source(mod_path), None)
index 64918bc03fefe9334067cf87b7c4b27ca0a7faea..cc121e54a0c33c33c456f2606efb481b48551ad3 100644 (file)
@@ -96,7 +96,7 @@ class _AssertRaisesContext(object):
                 self.obj_name = str(callable_obj)
         else:
             self.obj_name = None
-        self.expected_regex = expected_regexp
+        self.expected_regexp = expected_regexp
 
     def __enter__(self):
         return self
@@ -118,10 +118,10 @@ class _AssertRaisesContext(object):
             return False
         # store exception, without traceback, for later retrieval
         self.exception = exc_value.with_traceback(None)
-        if self.expected_regex is None:
+        if self.expected_regexp is None:
             return True
 
-        expected_regexp = self.expected_regex
+        expected_regexp = self.expected_regexp
         if isinstance(expected_regexp, (bytes, str)):
             expected_regexp = re.compile(expected_regexp)
         if not expected_regexp.search(str(exc_value)):
@@ -865,12 +865,12 @@ class TestCase(object):
         with context:
             callable_obj(*args, **kwargs)
 
-    def assertRegexpMatches(self, text, expected_regex, msg=None):
-        if isinstance(expected_regex, (str, bytes)):
-            expected_regex = re.compile(expected_regex)
-        if not expected_regex.search(text):
+    def assertRegexpMatches(self, text, expected_regexp, msg=None):
+        if isinstance(expected_regexp, (str, bytes)):
+            expected_regexp = re.compile(expected_regexp)
+        if not expected_regexp.search(text):
             msg = msg or "Regexp didn't match"
-            msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
+            msg = '%s: %r not found in %r' % (msg, expected_regexp.pattern, text)
             raise self.failureException(msg)