hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [03/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code
Date Tue, 21 Jun 2016 02:41:19 GMT
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py
new file mode 100644
index 0000000..370ca5f
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py
@@ -0,0 +1,287 @@
+"""TestSuite"""
+
+import sys
+import unittest
+from unittest2 import case, util
+
+__unittest = True
+
+
+class BaseTestSuite(unittest.TestSuite):
+    """A simple test suite that doesn't provide class or module shared fixtures.
+    """
+    def __init__(self, tests=()):
+        self._tests = []
+        self.addTests(tests)
+
+    def __repr__(self):
+        return "<%s tests=%s>" % (util.strclass(self.__class__), list(self))
+
+    def __eq__(self, other):
+        if not isinstance(other, self.__class__):
+            return NotImplemented
+        return list(self) == list(other)
+
+    def __ne__(self, other):
+        return not self == other
+
+    # Can't guarantee hash invariant, so flag as unhashable
+    __hash__ = None
+
+    def __iter__(self):
+        return iter(self._tests)
+
+    def countTestCases(self):
+        cases = 0
+        for test in self:
+            cases += test.countTestCases()
+        return cases
+
+    def addTest(self, test):
+        # sanity checks
+        if not hasattr(test, '__call__'):
+            raise TypeError("%r is not callable" % (repr(test),))
+        if isinstance(test, type) and issubclass(test,
+                                                 (case.TestCase, TestSuite)):
+            raise TypeError("TestCases and TestSuites must be instantiated "
+                            "before passing them to addTest()")
+        self._tests.append(test)
+
+    def addTests(self, tests):
+        if isinstance(tests, basestring):
+            raise TypeError("tests must be an iterable of tests, not a string")
+        for test in tests:
+            self.addTest(test)
+
+    def run(self, result):
+        for test in self:
+            if result.shouldStop:
+                break
+            test(result)
+        return result
+
+    def __call__(self, *args, **kwds):
+        return self.run(*args, **kwds)
+
+    def debug(self):
+        """Run the tests without collecting errors in a TestResult"""
+        for test in self:
+            test.debug()
+
+
+class TestSuite(BaseTestSuite):
+    """A test suite is a composite test consisting of a number of TestCases.
+
+    For use, create an instance of TestSuite, then add test case instances.
+    When all tests have been added, the suite can be passed to a test
+    runner, such as TextTestRunner. It will run the individual test cases
+    in the order in which they were added, aggregating the results. When
+    subclassing, do not forget to call the base class constructor.
+    """
+    
+
+    def run(self, result):
+        self._wrapped_run(result)
+        self._tearDownPreviousClass(None, result)
+        self._handleModuleTearDown(result)
+        return result
+
+    def debug(self):
+        """Run the tests without collecting errors in a TestResult"""
+        debug = _DebugResult()
+        self._wrapped_run(debug, True)
+        self._tearDownPreviousClass(None, debug)
+        self._handleModuleTearDown(debug)
+
+    ################################
+    # private methods
+    def _wrapped_run(self, result, debug=False):
+        for test in self:
+            if result.shouldStop:
+                break
+            
+            if _isnotsuite(test):
+                self._tearDownPreviousClass(test, result)
+                self._handleModuleFixture(test, result)
+                self._handleClassSetUp(test, result)
+                result._previousTestClass = test.__class__
+                
+                if (getattr(test.__class__, '_classSetupFailed', False) or 
+                    getattr(result, '_moduleSetUpFailed', False)):
+                    continue
+            
+            if hasattr(test, '_wrapped_run'):
+                test._wrapped_run(result, debug)
+            elif not debug:
+                test(result)
+            else:
+                test.debug()
+    
+    def _handleClassSetUp(self, test, result):
+        previousClass = getattr(result, '_previousTestClass', None)
+        currentClass = test.__class__
+        if currentClass == previousClass:
+            return
+        if result._moduleSetUpFailed:
+            return
+        if getattr(currentClass, "__unittest_skip__", False):
+            return
+        
+        try:
+            currentClass._classSetupFailed = False
+        except TypeError:
+            # test may actually be a function
+            # so its class will be a builtin-type
+            pass
+            
+        setUpClass = getattr(currentClass, 'setUpClass', None)
+        if setUpClass is not None:
+            try:
+                setUpClass()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                currentClass._classSetupFailed = True
+                className = util.strclass(currentClass)
+                errorName = 'setUpClass (%s)' % className
+                self._addClassOrModuleLevelException(result, e, errorName)
+    
+    def _get_previous_module(self, result):
+        previousModule = None
+        previousClass = getattr(result, '_previousTestClass', None)
+        if previousClass is not None:
+            previousModule = previousClass.__module__
+        return previousModule
+        
+        
+    def _handleModuleFixture(self, test, result):
+        previousModule = self._get_previous_module(result)
+        currentModule = test.__class__.__module__
+        if currentModule == previousModule:
+            return
+        
+        self._handleModuleTearDown(result)
+
+        
+        result._moduleSetUpFailed = False
+        try:
+            module = sys.modules[currentModule]
+        except KeyError:
+            return
+        setUpModule = getattr(module, 'setUpModule', None)
+        if setUpModule is not None:
+            try:
+                setUpModule()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                result._moduleSetUpFailed = True
+                errorName = 'setUpModule (%s)' % currentModule
+                self._addClassOrModuleLevelException(result, e, errorName)
+
+    def _addClassOrModuleLevelException(self, result, exception, errorName):
+        error = _ErrorHolder(errorName)
+        addSkip = getattr(result, 'addSkip', None)
+        if addSkip is not None and isinstance(exception, case.SkipTest):
+            addSkip(error, str(exception))
+        else:
+            result.addError(error, sys.exc_info())
+    
+    def _handleModuleTearDown(self, result):
+        previousModule = self._get_previous_module(result)
+        if previousModule is None:
+            return
+        if result._moduleSetUpFailed:
+            return
+            
+        try:
+            module = sys.modules[previousModule]
+        except KeyError:
+            return
+
+        tearDownModule = getattr(module, 'tearDownModule', None)
+        if tearDownModule is not None:
+            try:
+                tearDownModule()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                errorName = 'tearDownModule (%s)' % previousModule
+                self._addClassOrModuleLevelException(result, e, errorName)
+    
+    def _tearDownPreviousClass(self, test, result):
+        previousClass = getattr(result, '_previousTestClass', None)
+        currentClass = test.__class__
+        if currentClass == previousClass:
+            return
+        if getattr(previousClass, '_classSetupFailed', False):
+            return
+        if getattr(result, '_moduleSetUpFailed', False):
+            return
+        if getattr(previousClass, "__unittest_skip__", False):
+            return
+        
+        tearDownClass = getattr(previousClass, 'tearDownClass', None)
+        if tearDownClass is not None:
+            try:
+                tearDownClass()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                className = util.strclass(previousClass)
+                errorName = 'tearDownClass (%s)' % className
+                self._addClassOrModuleLevelException(result, e, errorName)
+
+
+class _ErrorHolder(object):
+    """
+    Placeholder for a TestCase inside a result. As far as a TestResult
+    is concerned, this looks exactly like a unit test. Used to insert
+    arbitrary errors into a test suite run.
+    """
+    # Inspired by the ErrorHolder from Twisted:
+    # http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py
+
+    # attribute used by TestResult._exc_info_to_string
+    failureException = None
+
+    def __init__(self, description):
+        self.description = description
+
+    def id(self):
+        return self.description
+
+    def shortDescription(self):
+        return None
+
+    def __repr__(self):
+        return "<ErrorHolder description=%r>" % (self.description,)
+
+    def __str__(self):
+        return self.id()
+
+    def run(self, result):
+        # could call result.addError(...) - but this test-like object
+        # shouldn't be run anyway
+        pass
+
+    def __call__(self, result):
+        return self.run(result)
+
+    def countTestCases(self):
+        return 0
+
+def _isnotsuite(test):
+    "A crude way to tell apart testcases and suites with duck-typing"
+    try:
+        iter(test)
+    except TypeError:
+        return True
+    return False
+
+
+class _DebugResult(object):
+    "Used by the TestSuite to hold previous class when running in debug."
+    _previousTestClass = None
+    _moduleSetUpFailed = False
+    shouldStop = False

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py
new file mode 100644
index 0000000..4287ca8
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py
@@ -0,0 +1 @@
+#
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/dummy.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/dummy.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/dummy.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py
new file mode 100644
index 0000000..a006b45
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py
@@ -0,0 +1,177 @@
+import sys
+import warnings
+
+import unittest2
+
+
+def resultFactory(*_):
+    return unittest2.TestResult()
+
+class OldTestResult(object):
+    """An object honouring TestResult before startTestRun/stopTestRun."""
+
+    def __init__(self, *_):
+        self.failures = []
+        self.errors = []
+        self.testsRun = 0
+        self.shouldStop = False
+
+    def startTest(self, test):
+        pass
+
+    def stopTest(self, test):
+        pass
+
+    def addError(self, test, err):
+        self.errors.append((test, err))
+
+    def addFailure(self, test, err):
+        self.failures.append((test, err))
+
+    def addSuccess(self, test):
+        pass
+
+    def wasSuccessful(self):
+        return True
+
+    def printErrors(self):
+        pass
+
+class LoggingResult(unittest2.TestResult):
+    def __init__(self, log):
+        self._events = log
+        super(LoggingResult, self).__init__()
+
+    def startTest(self, test):
+        self._events.append('startTest')
+        super(LoggingResult, self).startTest(test)
+
+    def startTestRun(self):
+        self._events.append('startTestRun')
+        super(LoggingResult, self).startTestRun()
+
+    def stopTest(self, test):
+        self._events.append('stopTest')
+        super(LoggingResult, self).stopTest(test)
+
+    def stopTestRun(self):
+        self._events.append('stopTestRun')
+        super(LoggingResult, self).stopTestRun()
+
+    def addFailure(self, *args):
+        self._events.append('addFailure')
+        super(LoggingResult, self).addFailure(*args)
+
+    def addSuccess(self, *args):
+        self._events.append('addSuccess')
+        super(LoggingResult, self).addSuccess(*args)
+
+    def addError(self, *args):
+        self._events.append('addError')
+        super(LoggingResult, self).addError(*args)
+
+    def addSkip(self, *args):
+        self._events.append('addSkip')
+        super(LoggingResult, self).addSkip(*args)
+
+    def addExpectedFailure(self, *args):
+        self._events.append('addExpectedFailure')
+        super(LoggingResult, self).addExpectedFailure(*args)
+
+    def addUnexpectedSuccess(self, *args):
+        self._events.append('addUnexpectedSuccess')
+        super(LoggingResult, self).addUnexpectedSuccess(*args)
+
+
+class EqualityMixin(object):
+    """Used as a mixin for TestCase"""
+
+    # Check for a valid __eq__ implementation
+    def test_eq(self):
+        for obj_1, obj_2 in self.eq_pairs:
+            self.assertEqual(obj_1, obj_2)
+            self.assertEqual(obj_2, obj_1)
+
+    # Check for a valid __ne__ implementation
+    def test_ne(self):
+        for obj_1, obj_2 in self.ne_pairs:
+            self.assertNotEqual(obj_1, obj_2)
+            self.assertNotEqual(obj_2, obj_1)
+
+class HashingMixin(object):
+    """Used as a mixin for TestCase"""
+
+    # Check for a valid __hash__ implementation
+    def test_hash(self):
+        for obj_1, obj_2 in self.eq_pairs:
+            try:
+                if not hash(obj_1) == hash(obj_2):
+                    self.fail("%r and %r do not hash equal" % (obj_1, obj_2))
+            except KeyboardInterrupt:
+                raise
+            except Exception, e:
+                self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e))
+
+        for obj_1, obj_2 in self.ne_pairs:
+            try:
+                if hash(obj_1) == hash(obj_2):
+                    self.fail("%s and %s hash equal, but shouldn't" %
+                              (obj_1, obj_2))
+            except KeyboardInterrupt:
+                raise
+            except Exception, e:
+                self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e))
+
+
+
+# copied from Python 2.6
+try:
+    from warnings import catch_warnings
+except ImportError:
+    class catch_warnings(object):
+        def __init__(self, record=False, module=None):
+            self._record = record
+            self._module = sys.modules['warnings']
+            self._entered = False
+    
+        def __repr__(self):
+            args = []
+            if self._record:
+                args.append("record=True")
+            name = type(self).__name__
+            return "%s(%s)" % (name, ", ".join(args))
+    
+        def __enter__(self):
+            if self._entered:
+                raise RuntimeError("Cannot enter %r twice" % self)
+            self._entered = True
+            self._filters = self._module.filters
+            self._module.filters = self._filters[:]
+            self._showwarning = self._module.showwarning
+            if self._record:
+                log = []
+                def showwarning(*args, **kwargs):
+                    log.append(WarningMessage(*args, **kwargs))
+                self._module.showwarning = showwarning
+                return log
+            else:
+                return None
+    
+        def __exit__(self, *exc_info):
+            if not self._entered:
+                raise RuntimeError("Cannot exit %r without entering first" % self)
+            self._module.filters = self._filters
+            self._module.showwarning = self._showwarning
+
+    class WarningMessage(object):
+        _WARNING_DETAILS = ("message", "category", "filename", "lineno", "file",
+                            "line")
+        def __init__(self, message, category, filename, lineno, file=None,
+                        line=None):
+            local_values = locals()
+            for attr in self._WARNING_DETAILS:
+                setattr(self, attr, local_values[attr])
+            self._category_name = None
+            if category.__name__:
+                self._category_name = category.__name__
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py
new file mode 100644
index 0000000..02bdc86
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py
@@ -0,0 +1,254 @@
+import datetime
+
+import unittest2
+
+
+class Test_Assertions(unittest2.TestCase):
+    def test_AlmostEqual(self):
+        self.assertAlmostEqual(1.00000001, 1.0)
+        self.assertNotAlmostEqual(1.0000001, 1.0)
+        self.assertRaises(self.failureException,
+                          self.assertAlmostEqual, 1.0000001, 1.0)
+        self.assertRaises(self.failureException,
+                          self.assertNotAlmostEqual, 1.00000001, 1.0)
+
+        self.assertAlmostEqual(1.1, 1.0, places=0)
+        self.assertRaises(self.failureException,
+                          self.assertAlmostEqual, 1.1, 1.0, places=1)
+
+        self.assertAlmostEqual(0, .1+.1j, places=0)
+        self.assertNotAlmostEqual(0, .1+.1j, places=1)
+        self.assertRaises(self.failureException,
+                          self.assertAlmostEqual, 0, .1+.1j, places=1)
+        self.assertRaises(self.failureException,
+                          self.assertNotAlmostEqual, 0, .1+.1j, places=0)
+
+        try:
+            self.assertAlmostEqual(float('inf'), float('inf'))
+            self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+                              float('inf'), float('inf'))
+        except ValueError:
+            # float('inf') is invalid on Windows in Python 2.4 / 2.5
+            x = object()
+            self.assertAlmostEqual(x, x)
+            self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+                              x, x)
+            
+            
+    def test_AmostEqualWithDelta(self):
+        self.assertAlmostEqual(1.1, 1.0, delta=0.5)
+        self.assertAlmostEqual(1.0, 1.1, delta=0.5)
+        self.assertNotAlmostEqual(1.1, 1.0, delta=0.05)
+        self.assertNotAlmostEqual(1.0, 1.1, delta=0.05)
+        
+        self.assertRaises(self.failureException, self.assertAlmostEqual,
+                          1.1, 1.0, delta=0.05)
+        self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+                          1.1, 1.0, delta=0.5)
+        
+        self.assertRaises(TypeError, self.assertAlmostEqual,
+                          1.1, 1.0, places=2, delta=2)
+        self.assertRaises(TypeError, self.assertNotAlmostEqual,
+                          1.1, 1.0, places=2, delta=2)
+        
+        first = datetime.datetime.now()
+        second = first + datetime.timedelta(seconds=10)
+        self.assertAlmostEqual(first, second,
+                               delta=datetime.timedelta(seconds=20))
+        self.assertNotAlmostEqual(first, second,
+                                  delta=datetime.timedelta(seconds=5))
+
+    def testAssertNotRegexpMatches(self):
+        self.assertNotRegexpMatches('Ala ma kota', r'r+')
+        try:
+            self.assertNotRegexpMatches('Ala ma kota', r'k.t', 'Message')
+        except self.failureException, e:
+            self.assertIn("'kot'", e.args[0])
+            self.assertIn('Message', e.args[0])
+        else:
+            self.fail('assertNotRegexpMatches should have failed.')
+
+
+class TestLongMessage(unittest2.TestCase):
+    """Test that the individual asserts honour longMessage.
+    This actually tests all the message behaviour for
+    asserts that use longMessage."""
+
+    def setUp(self):
+        class TestableTestFalse(unittest2.TestCase):
+            longMessage = False
+            failureException = self.failureException
+
+            def testTest(self):
+                pass
+
+        class TestableTestTrue(unittest2.TestCase):
+            longMessage = True
+            failureException = self.failureException
+
+            def testTest(self):
+                pass
+
+        self.testableTrue = TestableTestTrue('testTest')
+        self.testableFalse = TestableTestFalse('testTest')
+
+    def testDefault(self):
+        self.assertTrue(unittest2.TestCase.longMessage)
+
+    def test_formatMsg(self):
+        self.assertEquals(self.testableFalse._formatMessage(None, "foo"), "foo")
+        self.assertEquals(self.testableFalse._formatMessage("foo", "bar"), "foo")
+
+        self.assertEquals(self.testableTrue._formatMessage(None, "foo"), "foo")
+        self.assertEquals(self.testableTrue._formatMessage("foo", "bar"), "bar : foo")
+        
+        # This blows up if _formatMessage uses string concatenation
+        self.testableTrue._formatMessage(object(), 'foo')
+
+    def assertMessages(self, methodName, args, errors):
+        def getMethod(i):
+            useTestableFalse  = i < 2
+            if useTestableFalse:
+                test = self.testableFalse
+            else:
+                test = self.testableTrue
+            return getattr(test, methodName)
+
+        for i, expected_regexp in enumerate(errors):
+            testMethod = getMethod(i)
+            kwargs = {}
+            withMsg = i % 2
+            if withMsg:
+                kwargs = {"msg": "oops"}
+
+            self.assertRaisesRegexp(self.failureException,
+                                    expected_regexp,
+                                    lambda: testMethod(*args, **kwargs))
+            
+    def testAssertTrue(self):
+        self.assertMessages('assertTrue', (False,),
+                            ["^False is not True$", "^oops$", "^False is not True$",
+                             "^False is not True : oops$"])
+
+    def testAssertFalse(self):
+        self.assertMessages('assertFalse', (True,),
+                            ["^True is not False$", "^oops$", "^True is not False$",
+                             "^True is not False : oops$"])
+
+    def testNotEqual(self):
+        self.assertMessages('assertNotEqual', (1, 1),
+                            ["^1 == 1$", "^oops$", "^1 == 1$",
+                             "^1 == 1 : oops$"])
+
+    def testAlmostEqual(self):
+        self.assertMessages('assertAlmostEqual', (1, 2),
+                            ["^1 != 2 within 7 places$", "^oops$",
+                             "^1 != 2 within 7 places$", "^1 != 2 within 7 places : oops$"])
+
+    def testNotAlmostEqual(self):
+        self.assertMessages('assertNotAlmostEqual', (1, 1),
+                            ["^1 == 1 within 7 places$", "^oops$",
+                             "^1 == 1 within 7 places$", "^1 == 1 within 7 places : oops$"])
+
+    def test_baseAssertEqual(self):
+        self.assertMessages('_baseAssertEqual', (1, 2),
+                            ["^1 != 2$", "^oops$", "^1 != 2$", "^1 != 2 : oops$"])
+
+    def testAssertSequenceEqual(self):
+        # Error messages are multiline so not testing on full message
+        # assertTupleEqual and assertListEqual delegate to this method
+        self.assertMessages('assertSequenceEqual', ([], [None]),
+                            ["\+ \[None\]$", "^oops$", r"\+ \[None\]$",
+                             r"\+ \[None\] : oops$"])
+
+    def testAssertSetEqual(self):
+        self.assertMessages('assertSetEqual', (set(), set([None])),
+                            ["None$", "^oops$", "None$",
+                             "None : oops$"])
+
+    def testAssertIn(self):
+        self.assertMessages('assertIn', (None, []),
+                            ['^None not found in \[\]$', "^oops$",
+                             '^None not found in \[\]$',
+                             '^None not found in \[\] : oops$'])
+
+    def testAssertNotIn(self):
+        self.assertMessages('assertNotIn', (None, [None]),
+                            ['^None unexpectedly found in \[None\]$', "^oops$",
+                             '^None unexpectedly found in \[None\]$',
+                             '^None unexpectedly found in \[None\] : oops$'])
+
+    def testAssertDictEqual(self):
+        self.assertMessages('assertDictEqual', ({}, {'key': 'value'}),
+                            [r"\+ \{'key': 'value'\}$", "^oops$",
+                             "\+ \{'key': 'value'\}$",
+                             "\+ \{'key': 'value'\} : oops$"])
+
+    def testAssertDictContainsSubset(self):
+        self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
+                            ["^Missing: 'key'$", "^oops$",
+                             "^Missing: 'key'$",
+                             "^Missing: 'key' : oops$"])
+
+    def testAssertItemsEqual(self):
+        self.assertMessages('assertItemsEqual', ([], [None]),
+                            [r"\[None\]$", "^oops$",
+                             r"\[None\]$",
+                             r"\[None\] : oops$"])
+
+    def testAssertMultiLineEqual(self):
+        self.assertMessages('assertMultiLineEqual', ("", "foo"),
+                            [r"\+ foo$", "^oops$",
+                             r"\+ foo$",
+                             r"\+ foo : oops$"])
+
+    def testAssertLess(self):
+        self.assertMessages('assertLess', (2, 1),
+                            ["^2 not less than 1$", "^oops$",
+                             "^2 not less than 1$", "^2 not less than 1 : oops$"])
+
+    def testAssertLessEqual(self):
+        self.assertMessages('assertLessEqual', (2, 1),
+                            ["^2 not less than or equal to 1$", "^oops$",
+                             "^2 not less than or equal to 1$",
+                             "^2 not less than or equal to 1 : oops$"])
+
+    def testAssertGreater(self):
+        self.assertMessages('assertGreater', (1, 2),
+                            ["^1 not greater than 2$", "^oops$",
+                             "^1 not greater than 2$",
+                             "^1 not greater than 2 : oops$"])
+
+    def testAssertGreaterEqual(self):
+        self.assertMessages('assertGreaterEqual', (1, 2),
+                            ["^1 not greater than or equal to 2$", "^oops$",
+                             "^1 not greater than or equal to 2$",
+                             "^1 not greater than or equal to 2 : oops$"])
+
+    def testAssertIsNone(self):
+        self.assertMessages('assertIsNone', ('not None',),
+                            ["^'not None' is not None$", "^oops$",
+                             "^'not None' is not None$",
+                             "^'not None' is not None : oops$"])
+
+    def testAssertIsNotNone(self):
+        self.assertMessages('assertIsNotNone', (None,),
+                            ["^unexpectedly None$", "^oops$",
+                             "^unexpectedly None$",
+                             "^unexpectedly None : oops$"])
+
+    def testAssertIs(self):
+        self.assertMessages('assertIs', (None, 'foo'),
+                            ["^None is not 'foo'$", "^oops$",
+                             "^None is not 'foo'$",
+                             "^None is not 'foo' : oops$"])
+
+    def testAssertIsNot(self):
+        self.assertMessages('assertIsNot', (None, None),
+                            ["^unexpectedly identical: None$", "^oops$",
+                             "^unexpectedly identical: None$",
+                             "^unexpectedly identical: None : oops$"])
+
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py
new file mode 100644
index 0000000..1f7864b
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py
@@ -0,0 +1,260 @@
+import gc
+import os
+import weakref
+
+from cStringIO import StringIO
+
+try:
+    import signal
+except ImportError:
+    signal = None
+
+import unittest2
+
+
+class TestBreak(unittest2.TestCase):
+    
+    def setUp(self):
+        self._default_handler = signal.getsignal(signal.SIGINT)
+        
+    def tearDown(self):
+        signal.signal(signal.SIGINT, self._default_handler)
+        unittest2.signals._results = weakref.WeakKeyDictionary()
+        unittest2.signals._interrupt_handler = None
+
+        
+    def testInstallHandler(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        unittest2.installHandler()
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        try:
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        except KeyboardInterrupt:
+            self.fail("KeyboardInterrupt not handled")
+            
+        self.assertTrue(unittest2.signals._interrupt_handler.called)
+    
+    def testRegisterResult(self):
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        
+        for ref in unittest2.signals._results:
+            if ref is result:
+                break
+            elif ref is not result:
+                self.fail("odd object in result set")
+        else:
+            self.fail("result not found")
+        
+        
+    def testInterruptCaught(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        
+        result = unittest2.TestResult()
+        unittest2.installHandler()
+        unittest2.registerResult(result)
+        
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        def test(result):
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+            result.breakCaught = True
+            self.assertTrue(result.shouldStop)
+        
+        try:
+            test(result)
+        except KeyboardInterrupt:
+            self.fail("KeyboardInterrupt not handled")
+        self.assertTrue(result.breakCaught)
+    
+    
+    def testSecondInterrupt(self):
+        result = unittest2.TestResult()
+        unittest2.installHandler()
+        unittest2.registerResult(result)
+        
+        def test(result):
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+            result.breakCaught = True
+            self.assertTrue(result.shouldStop)
+            os.kill(pid, signal.SIGINT)
+            self.fail("Second KeyboardInterrupt not raised")
+        
+        try:
+            test(result)
+        except KeyboardInterrupt:
+            pass
+        else:
+            self.fail("Second KeyboardInterrupt not raised")
+        self.assertTrue(result.breakCaught)
+
+    
+    def testTwoResults(self):
+        unittest2.installHandler()
+        
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        new_handler = signal.getsignal(signal.SIGINT)
+        
+        result2 = unittest2.TestResult()
+        unittest2.registerResult(result2)
+        self.assertEqual(signal.getsignal(signal.SIGINT), new_handler)
+        
+        result3 = unittest2.TestResult()
+        
+        def test(result):
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        
+        try:
+            test(result)
+        except KeyboardInterrupt:
+            self.fail("KeyboardInterrupt not handled")
+        
+        self.assertTrue(result.shouldStop)
+        self.assertTrue(result2.shouldStop)
+        self.assertFalse(result3.shouldStop)
+    
+    
+    def testHandlerReplacedButCalled(self):
+        # If our handler has been replaced (is no longer installed) but is
+        # called by the *new* handler, then it isn't safe to delay the
+        # SIGINT and we should immediately delegate to the default handler
+        unittest2.installHandler()
+        
+        handler = signal.getsignal(signal.SIGINT)
+        def new_handler(frame, signum):
+            handler(frame, signum)
+        signal.signal(signal.SIGINT, new_handler)
+        
+        try:
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        except KeyboardInterrupt:
+            pass
+        else:
+            self.fail("replaced but delegated handler doesn't raise interrupt")
+    
+    def testRunner(self):
+        # Creating a TextTestRunner with the appropriate argument should
+        # register the TextTestResult it creates
+        runner = unittest2.TextTestRunner(stream=StringIO())
+        
+        result = runner.run(unittest2.TestSuite())
+        self.assertIn(result, unittest2.signals._results)
+    
+    def testWeakReferences(self):
+        # Calling registerResult on a result should not keep it alive
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        
+        ref = weakref.ref(result)
+        del result
+        
+        # For non-reference counting implementations
+        gc.collect();gc.collect()
+        self.assertIsNone(ref())
+        
+    
+    def testRemoveResult(self):
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        
+        unittest2.installHandler()
+        self.assertTrue(unittest2.removeResult(result))
+        
+        # Should this raise an error instead?
+        self.assertFalse(unittest2.removeResult(unittest2.TestResult()))
+
+        try:
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        except KeyboardInterrupt:
+            pass
+        
+        self.assertFalse(result.shouldStop)
+    
+    def testMainInstallsHandler(self):
+        failfast = object()
+        test = object()
+        verbosity = object()
+        result = object()
+        default_handler = signal.getsignal(signal.SIGINT)
+
+        class FakeRunner(object):
+            initArgs = []
+            runArgs = []
+            def __init__(self, *args, **kwargs):
+                self.initArgs.append((args, kwargs))
+            def run(self, test):
+                self.runArgs.append(test)
+                return result
+        
+        class Program(unittest2.TestProgram):
+            def __init__(self, catchbreak): 
+                self.exit = False
+                self.verbosity = verbosity
+                self.failfast = failfast
+                self.catchbreak = catchbreak
+                self.testRunner = FakeRunner
+                self.test = test
+                self.result = None
+        
+        p = Program(False)
+        p.runTests()
+        
+        self.assertEqual(FakeRunner.initArgs, [((), {'verbosity': verbosity, 
+                                                'failfast': failfast,
+                                                'buffer': None})])
+        self.assertEqual(FakeRunner.runArgs, [test])
+        self.assertEqual(p.result, result)
+        
+        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        FakeRunner.initArgs = []
+        FakeRunner.runArgs = []
+        p = Program(True)
+        p.runTests()
+        
+        self.assertEqual(FakeRunner.initArgs, [((), {'verbosity': verbosity, 
+                                                'failfast': failfast,
+                                                'buffer': None})])
+        self.assertEqual(FakeRunner.runArgs, [test])
+        self.assertEqual(p.result, result)
+        
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+
+    def testRemoveHandler(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        unittest2.installHandler()
+        unittest2.removeHandler()
+        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+        # check that calling removeHandler multiple times has no ill-effect
+        unittest2.removeHandler()
+        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+    
+    def testRemoveHandlerAsDecorator(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        unittest2.installHandler()
+        
+        @unittest2.removeHandler
+        def test():
+            self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        test()
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+
+# Should also skip some tests on Jython
+skipper = unittest2.skipUnless(hasattr(os, 'kill') and signal is not None, 
+                               "test uses os.kill(...) and the signal module")
+TestBreak = skipper(TestBreak)
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py
new file mode 100644
index 0000000..2865c2e
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py
@@ -0,0 +1,1065 @@
+import difflib
+import pprint
+import re
+
+from copy import deepcopy
+
+import unittest2
+
+from unittest2.test.support import (
+    OldTestResult, EqualityMixin, HashingMixin, LoggingResult
+)
+
+
+class MyException(Exception):
+    pass
+
+
+class Test(object):
+    "Keep these TestCase classes out of the main namespace"
+
+    class Foo(unittest2.TestCase):
+        def runTest(self): pass
+        def test1(self): pass
+
+    class Bar(Foo):
+        def test2(self): pass
+
+    class LoggingTestCase(unittest2.TestCase):
+        """A test case which logs its calls."""
+
+        def __init__(self, events):
+            super(Test.LoggingTestCase, self).__init__('test')
+            self.events = events
+
+        def setUp(self):
+            self.events.append('setUp')
+
+        def test(self):
+            self.events.append('test')
+
+        def tearDown(self):
+            self.events.append('tearDown')
+
+
+
+class TestCleanUp(unittest2.TestCase):
+
+    def testCleanUp(self):
+        class TestableTest(unittest2.TestCase):
+            def testNothing(self):
+                pass
+
+        test = TestableTest('testNothing')
+        self.assertEqual(test._cleanups, [])
+
+        cleanups = []
+
+        def cleanup1(*args, **kwargs):
+            cleanups.append((1, args, kwargs))
+
+        def cleanup2(*args, **kwargs):
+            cleanups.append((2, args, kwargs))
+
+        test.addCleanup(cleanup1, 1, 2, 3, four='hello', five='goodbye')
+        test.addCleanup(cleanup2)
+
+        self.assertEqual(test._cleanups,
+                         [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
+                          (cleanup2, (), {})])
+
+        result = test.doCleanups()
+        self.assertTrue(result)
+
+        self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
+
+    def testCleanUpWithErrors(self):
+        class TestableTest(unittest2.TestCase):
+            def testNothing(self):
+                pass
+
+        class MockResult(object):
+            errors = []
+            def addError(self, test, exc_info):
+                self.errors.append((test, exc_info))
+
+        result = MockResult()
+        test = TestableTest('testNothing')
+        test._resultForDoCleanups = result
+
+        exc1 = Exception('foo')
+        exc2 = Exception('bar')
+        def cleanup1():
+            raise exc1
+
+        def cleanup2():
+            raise exc2
+
+        test.addCleanup(cleanup1)
+        test.addCleanup(cleanup2)
+
+        self.assertFalse(test.doCleanups())
+
+        (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors)
+        self.assertEqual((test1, Type1, instance1), (test, Exception, exc1))
+        self.assertEqual((test2, Type2, instance2), (test, Exception, exc2))
+
+    def testCleanupInRun(self):
+        blowUp = False
+        ordering = []
+
+        class TestableTest(unittest2.TestCase):
+            def setUp(self):
+                ordering.append('setUp')
+                if blowUp:
+                    raise Exception('foo')
+
+            def testNothing(self):
+                ordering.append('test')
+
+            def tearDown(self):
+                ordering.append('tearDown')
+
+        test = TestableTest('testNothing')
+
+        def cleanup1():
+            ordering.append('cleanup1')
+        def cleanup2():
+            ordering.append('cleanup2')
+        test.addCleanup(cleanup1)
+        test.addCleanup(cleanup2)
+
+        def success(some_test):
+            self.assertEqual(some_test, test)
+            ordering.append('success')
+
+        result = unittest2.TestResult()
+        result.addSuccess = success
+
+        test.run(result)
+        self.assertEqual(ordering, ['setUp', 'test', 'tearDown',
+                                    'cleanup2', 'cleanup1', 'success'])
+
+        blowUp = True
+        ordering = []
+        test = TestableTest('testNothing')
+        test.addCleanup(cleanup1)
+        test.run(result)
+        self.assertEqual(ordering, ['setUp', 'cleanup1'])
+
+    def testTestCaseDebugExecutesCleanups(self):
+        ordering = []
+
+        class TestableTest(unittest2.TestCase):
+            def setUp(self):
+                ordering.append('setUp')
+                self.addCleanup(cleanup1)
+
+            def testNothing(self):
+                ordering.append('test')
+
+            def tearDown(self):
+                ordering.append('tearDown')
+
+        test = TestableTest('testNothing')
+
+        def cleanup1():
+            ordering.append('cleanup1')
+            test.addCleanup(cleanup2)
+        def cleanup2():
+            ordering.append('cleanup2')
+
+        test.debug()
+        self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup1', 'cleanup2'])
+
+
+class Test_TestCase(unittest2.TestCase, EqualityMixin, HashingMixin):
+
+    ### Set up attributes used by inherited tests
+    ################################################################
+
+    # Used by HashingMixin.test_hash and EqualityMixin.test_eq
+    eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))]
+
+    # Used by EqualityMixin.test_ne
+    ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest')),
+                (Test.Foo('test1'), Test.Bar('test1')),
+                (Test.Foo('test1'), Test.Bar('test2'))]
+
+    ################################################################
+    ### /Set up attributes used by inherited tests
+
+
+    # "class TestCase([methodName])"
+    # ...
+    # "Each instance of TestCase will run a single test method: the
+    # method named methodName."
+    # ...
+    # "methodName defaults to "runTest"."
+    #
+    # Make sure it really is optional, and that it defaults to the proper
+    # thing.
+    def test_init__no_test_name(self):
+        class Test(unittest2.TestCase):
+            def runTest(self): raise MyException()
+            def test(self): pass
+
+        self.assertEqual(Test().id()[-13:], '.Test.runTest')
+
+    # "class TestCase([methodName])"
+    # ...
+    # "Each instance of TestCase will run a single test method: the
+    # method named methodName."
+    def test_init__test_name__valid(self):
+        class Test(unittest2.TestCase):
+            def runTest(self): raise MyException()
+            def test(self): pass
+
+        self.assertEqual(Test('test').id()[-10:], '.Test.test')
+
+    # "class unittest2.TestCase([methodName])"
+    # ...
+    # "Each instance of TestCase will run a single test method: the
+    # method named methodName."
+    def test_init__test_name__invalid(self):
+        class Test(unittest2.TestCase):
+            def runTest(self): raise MyException()
+            def test(self): pass
+
+        try:
+            Test('testfoo')
+        except ValueError:
+            pass
+        else:
+            self.fail("Failed to raise ValueError")
+
+    # "Return the number of tests represented by the this test object. For
+    # TestCase instances, this will always be 1"
+    def test_countTestCases(self):
+        class Foo(unittest2.TestCase):
+            def test(self): pass
+
+        self.assertEqual(Foo('test').countTestCases(), 1)
+
+    # "Return the default type of test result object to be used to run this
+    # test. For TestCase instances, this will always be
+    # unittest2.TestResult;  subclasses of TestCase should
+    # override this as necessary."
+    def test_defaultTestResult(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        result = Foo().defaultTestResult()
+        self.assertEqual(type(result), unittest2.TestResult)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if setUp() raises
+    # an exception.
+    def test_run_call_order__error_in_setUp(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def setUp(self):
+                super(Foo, self).setUp()
+                raise RuntimeError('raised by Foo.setUp')
+
+        Foo(events).run(result)
+        expected = ['startTest', 'setUp', 'addError', 'stopTest']
+        self.assertEqual(events, expected)
+
+    # "With a temporary result stopTestRun is called when setUp errors.
+    def test_run_call_order__error_in_setUp_default_result(self):
+        events = []
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+
+            def setUp(self):
+                super(Foo, self).setUp()
+                raise RuntimeError('raised by Foo.setUp')
+
+        Foo(events).run()
+        expected = ['startTestRun', 'startTest', 'setUp', 'addError',
+                    'stopTest', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if the test raises
+    # an error (as opposed to a failure).
+    def test_run_call_order__error_in_test(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def test(self):
+                super(Foo, self).test()
+                raise RuntimeError('raised by Foo.test')
+
+        expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
+                    'stopTest']
+        Foo(events).run(result)
+        self.assertEqual(events, expected)
+
+    # "With a default result, an error in the test still results in stopTestRun
+    # being called."
+    def test_run_call_order__error_in_test_default_result(self):
+        events = []
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+
+            def test(self):
+                super(Foo, self).test()
+                raise RuntimeError('raised by Foo.test')
+
+        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError',
+                    'tearDown', 'stopTest', 'stopTestRun']
+        Foo(events).run()
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if the test signals
+    # a failure (as opposed to an error).
+    def test_run_call_order__failure_in_test(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def test(self):
+                super(Foo, self).test()
+                self.fail('raised by Foo.test')
+
+        expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
+                    'stopTest']
+        Foo(events).run(result)
+        self.assertEqual(events, expected)
+
+    # "When a test fails with a default result stopTestRun is still called."
+    def test_run_call_order__failure_in_test_default_result(self):
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+            def test(self):
+                super(Foo, self).test()
+                self.fail('raised by Foo.test')
+
+        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure',
+                    'tearDown', 'stopTest', 'stopTestRun']
+        events = []
+        Foo(events).run()
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if tearDown() raises
+    # an exception.
+    def test_run_call_order__error_in_tearDown(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def tearDown(self):
+                super(Foo, self).tearDown()
+                raise RuntimeError('raised by Foo.tearDown')
+
+        Foo(events).run(result)
+        expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
+                    'stopTest']
+        self.assertEqual(events, expected)
+
+    # "When tearDown errors with a default result stopTestRun is still called."
+    def test_run_call_order__error_in_tearDown_default_result(self):
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+            def tearDown(self):
+                super(Foo, self).tearDown()
+                raise RuntimeError('raised by Foo.tearDown')
+
+        events = []
+        Foo(events).run()
+        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown',
+                    'addError', 'stopTest', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    # "TestCase.run() still works when the defaultTestResult is a TestResult
+    # that does not support startTestRun and stopTestRun.
+    def test_run_call_order_default_result(self):
+
+        class Foo(unittest2.TestCase):
+            def defaultTestResult(self):
+                return OldTestResult()
+            def test(self):
+                pass
+
+        Foo('test').run()
+
+    # "This class attribute gives the exception raised by the test() method.
+    # If a test framework needs to use a specialized exception, possibly to
+    # carry additional information, it must subclass this exception in
+    # order to ``play fair'' with the framework.  The initial value of this
+    # attribute is AssertionError"
+    def test_failureException__default(self):
+        class Foo(unittest2.TestCase):
+            def test(self):
+                pass
+
+        self.assertTrue(Foo('test').failureException is AssertionError)
+
+    # "This class attribute gives the exception raised by the test() method.
+    # If a test framework needs to use a specialized exception, possibly to
+    # carry additional information, it must subclass this exception in
+    # order to ``play fair'' with the framework."
+    #
+    # Make sure TestCase.run() respects the designated failureException
+    def test_failureException__subclassing__explicit_raise(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(unittest2.TestCase):
+            def test(self):
+                raise RuntimeError()
+
+            failureException = RuntimeError
+
+        self.assertTrue(Foo('test').failureException is RuntimeError)
+
+
+        Foo('test').run(result)
+        expected = ['startTest', 'addFailure', 'stopTest']
+        self.assertEqual(events, expected)
+
+    # "This class attribute gives the exception raised by the test() method.
+    # If a test framework needs to use a specialized exception, possibly to
+    # carry additional information, it must subclass this exception in
+    # order to ``play fair'' with the framework."
+    #
+    # Make sure TestCase.run() respects the designated failureException
+    def test_failureException__subclassing__implicit_raise(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(unittest2.TestCase):
+            def test(self):
+                self.fail("foo")
+
+            failureException = RuntimeError
+
+        self.assertTrue(Foo('test').failureException is RuntimeError)
+
+
+        Foo('test').run(result)
+        expected = ['startTest', 'addFailure', 'stopTest']
+        self.assertEqual(events, expected)
+
+    # "The default implementation does nothing."
+    def test_setUp(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        # ... and nothing should happen
+        Foo().setUp()
+
+    # "The default implementation does nothing."
+    def test_tearDown(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        # ... and nothing should happen
+        Foo().tearDown()
+
+    # "Return a string identifying the specific test case."
+    #
+    # Because of the vague nature of the docs, I'm not going to lock this
+    # test down too much. Really all that can be asserted is that the id()
+    # will be a string (either 8-byte or unicode -- again, because the docs
+    # just say "string")
+    def test_id(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        self.assertIsInstance(Foo().id(), basestring)
+
+    # "If result is omitted or None, a temporary result object is created
+    # and used, but is not made available to the caller. As TestCase owns the
+    # temporary result startTestRun and stopTestRun are called.
+
+    def test_run__uses_defaultTestResult(self):
+        events = []
+
+        class Foo(unittest2.TestCase):
+            def test(self):
+                events.append('test')
+
+            def defaultTestResult(self):
+                return LoggingResult(events)
+
+        # Make run() find a result object on its own
+        Foo('test').run()
+
+        expected = ['startTestRun', 'startTest', 'test', 'addSuccess',
+            'stopTest', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    def testShortDescriptionWithoutDocstring(self):
+        self.assertIsNone(self.shortDescription())
+
+    def testShortDescriptionWithOneLineDocstring(self):
+        """Tests shortDescription() for a method with a docstring."""
+        self.assertEqual(
+                self.shortDescription(),
+                'Tests shortDescription() for a method with a docstring.')
+
+    def testShortDescriptionWithMultiLineDocstring(self):
+        """Tests shortDescription() for a method with a longer docstring.
+
+        This method ensures that only the first line of a docstring is
+        returned used in the short description, no matter how long the
+        whole thing is.
+        """
+        self.assertEqual(
+                self.shortDescription(),
+                 'Tests shortDescription() for a method with a longer '
+                 'docstring.')
+
+    def testAddTypeEqualityFunc(self):
+        class SadSnake(object):
+            """Dummy class for test_addTypeEqualityFunc."""
+        s1, s2 = SadSnake(), SadSnake()
+        self.assertNotEqual(s1, s2)
+        def AllSnakesCreatedEqual(a, b, msg=None):
+            return type(a) is type(b) is SadSnake
+        self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual)
+        self.assertEqual(s1, s2)
+        # No this doesn't clean up and remove the SadSnake equality func
+        # from this TestCase instance but since its a local nothing else
+        # will ever notice that.
+
+    def testAssertIs(self):
+        thing = object()
+        self.assertIs(thing, thing)
+        self.assertRaises(self.failureException, self.assertIs, thing, object())
+
+    def testAssertIsNot(self):
+        thing = object()
+        self.assertIsNot(thing, object())
+        self.assertRaises(self.failureException, self.assertIsNot, thing, thing)
+
+    def testAssertIsInstance(self):
+        thing = []
+        self.assertIsInstance(thing, list)
+        self.assertRaises(self.failureException, self.assertIsInstance,
+                          thing, dict)
+
+    def testAssertNotIsInstance(self):
+        thing = []
+        self.assertNotIsInstance(thing, dict)
+        self.assertRaises(self.failureException, self.assertNotIsInstance,
+                          thing, list)
+
+    def testAssertIn(self):
+        animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'}
+
+        self.assertIn('a', 'abc')
+        self.assertIn(2, [1, 2, 3])
+        self.assertIn('monkey', animals)
+
+        self.assertNotIn('d', 'abc')
+        self.assertNotIn(0, [1, 2, 3])
+        self.assertNotIn('otter', animals)
+
+        self.assertRaises(self.failureException, self.assertIn, 'x', 'abc')
+        self.assertRaises(self.failureException, self.assertIn, 4, [1, 2, 3])
+        self.assertRaises(self.failureException, self.assertIn, 'elephant',
+                          animals)
+
+        self.assertRaises(self.failureException, self.assertNotIn, 'c', 'abc')
+        self.assertRaises(self.failureException, self.assertNotIn, 1, [1, 2, 3])
+        self.assertRaises(self.failureException, self.assertNotIn, 'cow',
+                          animals)
+
+    def testAssertDictContainsSubset(self):
+        self.assertDictContainsSubset({}, {})
+        self.assertDictContainsSubset({}, {'a': 1})
+        self.assertDictContainsSubset({'a': 1}, {'a': 1})
+        self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
+        self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'a': 2}, {'a': 1},
+                          '.*Mismatched values:.*')
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'c': 1}, {'a': 1},
+                          '.*Missing:.*')
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'a': 1, 'c': 1},
+                          {'a': 1}, '.*Missing:.*')
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'a': 1, 'c': 1},
+                          {'a': 1}, '.*Missing:.*Mismatched values:.*')
+        
+        self.assertRaises(self.failureException,
+                          self.assertDictContainsSubset, {1: "one"}, {})
+
+    def testAssertEqual(self):
+        equal_pairs = [
+                ((), ()),
+                ({}, {}),
+                ([], []),
+                (set(), set()),
+                (frozenset(), frozenset())]
+        for a, b in equal_pairs:
+            # This mess of try excepts is to test the assertEqual behavior
+            # itself.
+            try:
+                self.assertEqual(a, b)
+            except self.failureException:
+                self.fail('assertEqual(%r, %r) failed' % (a, b))
+            try:
+                self.assertEqual(a, b, msg='foo')
+            except self.failureException:
+                self.fail('assertEqual(%r, %r) with msg= failed' % (a, b))
+            try:
+                self.assertEqual(a, b, 'foo')
+            except self.failureException:
+                self.fail('assertEqual(%r, %r) with third parameter failed' %
+                          (a, b))
+
+        unequal_pairs = [
+               ((), []),
+               ({}, set()),
+               (set([4,1]), frozenset([4,2])),
+               (frozenset([4,5]), set([2,3])),
+               (set([3,4]), set([5,4]))]
+        for a, b in unequal_pairs:
+            self.assertRaises(self.failureException, self.assertEqual, a, b)
+            self.assertRaises(self.failureException, self.assertEqual, a, b,
+                              'foo')
+            self.assertRaises(self.failureException, self.assertEqual, a, b,
+                              msg='foo')
+
+    def testEquality(self):
+        self.assertListEqual([], [])
+        self.assertTupleEqual((), ())
+        self.assertSequenceEqual([], ())
+
+        a = [0, 'a', []]
+        b = []
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertListEqual, a, b)
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertListEqual, tuple(a), tuple(b))
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertSequenceEqual, a, tuple(b))
+
+        b.extend(a)
+        self.assertListEqual(a, b)
+        self.assertTupleEqual(tuple(a), tuple(b))
+        self.assertSequenceEqual(a, tuple(b))
+        self.assertSequenceEqual(tuple(a), b)
+
+        self.assertRaises(self.failureException, self.assertListEqual,
+                          a, tuple(b))
+        self.assertRaises(self.failureException, self.assertTupleEqual,
+                          tuple(a), b)
+        self.assertRaises(self.failureException, self.assertListEqual, None, b)
+        self.assertRaises(self.failureException, self.assertTupleEqual, None,
+                          tuple(b))
+        self.assertRaises(self.failureException, self.assertSequenceEqual,
+                          None, tuple(b))
+        self.assertRaises(self.failureException, self.assertListEqual, 1, 1)
+        self.assertRaises(self.failureException, self.assertTupleEqual, 1, 1)
+        self.assertRaises(self.failureException, self.assertSequenceEqual,
+                          1, 1)
+
+        self.assertDictEqual({}, {})
+
+        c = { 'x': 1 }
+        d = {}
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictEqual, c, d)
+
+        d.update(c)
+        self.assertDictEqual(c, d)
+
+        d['x'] = 0
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictEqual, c, d, 'These are unequal')
+
+        self.assertRaises(self.failureException, self.assertDictEqual, None, d)
+        self.assertRaises(self.failureException, self.assertDictEqual, [], d)
+        self.assertRaises(self.failureException, self.assertDictEqual, 1, 1)
+
+    def testAssertItemsEqual(self):
+        self.assertItemsEqual([1, 2, 3], [3, 2, 1])
+        self.assertItemsEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [10], [10, 11])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [10, 11], [10])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [10, 11, 10], [10, 11])
+
+        # Test that sequences of unhashable objects can be tested for sameness:
+        self.assertItemsEqual([[1, 2], [3, 4]], [[3, 4], [1, 2]])
+
+        self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [[1]], [[2]])
+        
+        # Test unsortable objects
+        self.assertItemsEqual([2j, None], [None, 2j])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [2j, None], [None, 3j])
+
+    def testAssertSetEqual(self):
+        set1 = set()
+        set2 = set()
+        self.assertSetEqual(set1, set2)
+
+        self.assertRaises(self.failureException, self.assertSetEqual, None, set2)
+        self.assertRaises(self.failureException, self.assertSetEqual, [], set2)
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, None)
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, [])
+
+        set1 = set(['a'])
+        set2 = set()
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+        set1 = set(['a'])
+        set2 = set(['a'])
+        self.assertSetEqual(set1, set2)
+
+        set1 = set(['a'])
+        set2 = set(['a', 'b'])
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+        set1 = set(['a'])
+        set2 = frozenset(['a', 'b'])
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+        set1 = set(['a', 'b'])
+        set2 = frozenset(['a', 'b'])
+        self.assertSetEqual(set1, set2)
+
+        set1 = set()
+        set2 = "foo"
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+        self.assertRaises(self.failureException, self.assertSetEqual, set2, set1)
+
+        # make sure any string formatting is tuple-safe
+        set1 = set([(0, 1), (2, 3)])
+        set2 = set([(4, 5)])
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+    def testInequality(self):
+        # Try ints
+        self.assertGreater(2, 1)
+        self.assertGreaterEqual(2, 1)
+        self.assertGreaterEqual(1, 1)
+        self.assertLess(1, 2)
+        self.assertLessEqual(1, 2)
+        self.assertLessEqual(1, 1)
+        self.assertRaises(self.failureException, self.assertGreater, 1, 2)
+        self.assertRaises(self.failureException, self.assertGreater, 1, 1)
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 1, 2)
+        self.assertRaises(self.failureException, self.assertLess, 2, 1)
+        self.assertRaises(self.failureException, self.assertLess, 1, 1)
+        self.assertRaises(self.failureException, self.assertLessEqual, 2, 1)
+
+        # Try Floats
+        self.assertGreater(1.1, 1.0)
+        self.assertGreaterEqual(1.1, 1.0)
+        self.assertGreaterEqual(1.0, 1.0)
+        self.assertLess(1.0, 1.1)
+        self.assertLessEqual(1.0, 1.1)
+        self.assertLessEqual(1.0, 1.0)
+        self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.1)
+        self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.0)
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 1.0, 1.1)
+        self.assertRaises(self.failureException, self.assertLess, 1.1, 1.0)
+        self.assertRaises(self.failureException, self.assertLess, 1.0, 1.0)
+        self.assertRaises(self.failureException, self.assertLessEqual, 1.1, 1.0)
+
+        # Try Strings
+        self.assertGreater('bug', 'ant')
+        self.assertGreaterEqual('bug', 'ant')
+        self.assertGreaterEqual('ant', 'ant')
+        self.assertLess('ant', 'bug')
+        self.assertLessEqual('ant', 'bug')
+        self.assertLessEqual('ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', 'bug')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', 'bug')
+        self.assertRaises(self.failureException, self.assertLess, 'bug', 'ant')
+        self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant')
+
+        # Try Unicode
+        self.assertGreater(u'bug', u'ant')
+        self.assertGreaterEqual(u'bug', u'ant')
+        self.assertGreaterEqual(u'ant', u'ant')
+        self.assertLess(u'ant', u'bug')
+        self.assertLessEqual(u'ant', u'bug')
+        self.assertLessEqual(u'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', u'bug')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
+                          u'bug')
+        self.assertRaises(self.failureException, self.assertLess, u'bug', u'ant')
+        self.assertRaises(self.failureException, self.assertLess, u'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, u'bug', u'ant')
+
+        # Try Mixed String/Unicode
+        self.assertGreater('bug', u'ant')
+        self.assertGreater(u'bug', 'ant')
+        self.assertGreaterEqual('bug', u'ant')
+        self.assertGreaterEqual(u'bug', 'ant')
+        self.assertGreaterEqual('ant', u'ant')
+        self.assertGreaterEqual(u'ant', 'ant')
+        self.assertLess('ant', u'bug')
+        self.assertLess(u'ant', 'bug')
+        self.assertLessEqual('ant', u'bug')
+        self.assertLessEqual(u'ant', 'bug')
+        self.assertLessEqual('ant', u'ant')
+        self.assertLessEqual(u'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', u'bug')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', 'bug')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant',
+                          u'bug')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
+                          'bug')
+        self.assertRaises(self.failureException, self.assertLess, 'bug', u'ant')
+        self.assertRaises(self.failureException, self.assertLess, u'bug', 'ant')
+        self.assertRaises(self.failureException, self.assertLess, 'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertLess, u'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, 'bug', u'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, u'bug', 'ant')
+
+    def testAssertMultiLineEqual(self):
+        sample_text = """\
+http://www.python.org/doc/2.3/lib/module-unittest.html
+test case
+    A test case is the smallest unit of testing. [...]
+"""
+        revised_sample_text = """\
+http://www.python.org/doc/2.4.1/lib/module-unittest.html
+test case
+    A test case is the smallest unit of testing. [...] You may provide your
+    own implementation that does not subclass from TestCase, of course.
+"""
+        sample_text_error = """\
+- http://www.python.org/doc/2.3/lib/module-unittest.html
+?                             ^
++ http://www.python.org/doc/2.4.1/lib/module-unittest.html
+?                             ^^^
+  test case
+-     A test case is the smallest unit of testing. [...]
++     A test case is the smallest unit of testing. [...] You may provide your
+?                                                       +++++++++++++++++++++
++     own implementation that does not subclass from TestCase, of course.
+"""
+        self.maxDiff = None
+        for type_changer in (lambda x: x, lambda x: x.decode('utf8')):
+            try:
+                self.assertMultiLineEqual(type_changer(sample_text),
+                                          type_changer(revised_sample_text))
+            except self.failureException, e:
+                # need to remove the first line of the error message
+                error = str(e).encode('utf8').split('\n', 1)[1]
+
+                # assertMultiLineEqual is hooked up as the default for
+                # unicode strings - so we can't use it for this check
+                self.assertTrue(sample_text_error == error)
+
+    def testAssertSequenceEqualMaxDiff(self):
+        self.assertEqual(self.maxDiff, 80*8)
+        seq1 = 'a' + 'x' * 80**2
+        seq2 = 'b' + 'x' * 80**2
+        diff = '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(),
+                                       pprint.pformat(seq2).splitlines()))
+        # the +1 is the leading \n added by assertSequenceEqual
+        omitted = unittest2.case.DIFF_OMITTED % (len(diff) + 1,)
+
+        self.maxDiff = len(diff)//2
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException, e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) < len(diff))
+        self.assertIn(omitted, msg)
+
+        self.maxDiff = len(diff) * 2
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException, e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) > len(diff))
+        self.assertNotIn(omitted, msg)
+
+        self.maxDiff = None
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException, e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) > len(diff))
+        self.assertNotIn(omitted, msg)
+
+    def testTruncateMessage(self):
+        self.maxDiff = 1
+        message = self._truncateMessage('foo', 'bar')
+        omitted = unittest2.case.DIFF_OMITTED % len('bar')
+        self.assertEqual(message, 'foo' + omitted)
+
+        self.maxDiff = None
+        message = self._truncateMessage('foo', 'bar')
+        self.assertEqual(message, 'foobar')
+
+        self.maxDiff = 4
+        message = self._truncateMessage('foo', 'bar')
+        self.assertEqual(message, 'foobar')
+
+    def testAssertDictEqualTruncates(self):
+        test = unittest2.TestCase('assertEqual')
+        def truncate(msg, diff):
+            return 'foo'
+        test._truncateMessage = truncate
+        try:
+            test.assertDictEqual({}, {1: 0})
+        except self.failureException, e:
+            self.assertEqual(str(e), 'foo')
+        else:
+            self.fail('assertDictEqual did not fail')
+
+    def testAssertMultiLineEqualTruncates(self):
+        test = unittest2.TestCase('assertEqual')
+        def truncate(msg, diff):
+            return 'foo'
+        test._truncateMessage = truncate
+        try:
+            test.assertMultiLineEqual('foo', 'bar')
+        except self.failureException, e:
+            self.assertEqual(str(e), 'foo')
+        else:
+            self.fail('assertMultiLineEqual did not fail')
+
+    def testAssertIsNone(self):
+        self.assertIsNone(None)
+        self.assertRaises(self.failureException, self.assertIsNone, False)
+        self.assertIsNotNone('DjZoPloGears on Rails')
+        self.assertRaises(self.failureException, self.assertIsNotNone, None)
+
+    def testAssertRegexpMatches(self):
+        self.assertRegexpMatches('asdfabasdf', r'ab+')
+        self.assertRaises(self.failureException, self.assertRegexpMatches,
+                          'saaas', r'aaaa')
+
+    def testAssertRaisesRegexp(self):
+        class ExceptionMock(Exception):
+            pass
+
+        def Stub():
+            raise ExceptionMock('We expect')
+
+        self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub)
+        self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub)
+        self.assertRaisesRegexp(ExceptionMock, u'expect$', Stub)
+
+    def testAssertNotRaisesRegexp(self):
+        self.assertRaisesRegexp(
+                self.failureException, '^Exception not raised$',
+                self.assertRaisesRegexp, Exception, re.compile('x'),
+                lambda: None)
+        self.assertRaisesRegexp(
+                self.failureException, '^Exception not raised$',
+                self.assertRaisesRegexp, Exception, 'x',
+                lambda: None)
+        self.assertRaisesRegexp(
+                self.failureException, '^Exception not raised$',
+                self.assertRaisesRegexp, Exception, u'x',
+                lambda: None)
+
+    def testAssertRaisesRegexpMismatch(self):
+        def Stub():
+            raise Exception('Unexpected')
+
+        self.assertRaisesRegexp(
+                self.failureException,
+                r'"\^Expected\$" does not match "Unexpected"',
+                self.assertRaisesRegexp, Exception, '^Expected$',
+                Stub)
+        self.assertRaisesRegexp(
+                self.failureException,
+                r'"\^Expected\$" does not match "Unexpected"',
+                self.assertRaisesRegexp, Exception, u'^Expected$',
+                Stub)
+        self.assertRaisesRegexp(
+                self.failureException,
+                r'"\^Expected\$" does not match "Unexpected"',
+                self.assertRaisesRegexp, Exception,
+                re.compile('^Expected$'), Stub)
+
+
+    def testSynonymAssertMethodNames(self):
+        """Test undocumented method name synonyms.
+
+        Please do not use these methods names in your own code.
+
+        This test confirms their continued existence and functionality
+        in order to avoid breaking existing code.
+        """
+        self.assertNotEquals(3, 5)
+        self.assertEquals(3, 3)
+        self.assertAlmostEquals(2.0, 2.0)
+        self.assertNotAlmostEquals(3.0, 5.0)
+        self.assert_(True)
+
+    def testDeepcopy(self):
+        # Issue: 5660
+        class TestableTest(unittest2.TestCase):
+            def testNothing(self):
+                pass
+
+        test = TestableTest('testNothing')
+
+        # This shouldn't blow up
+        deepcopy(test)
+
+
+if __name__ == "__main__":
+    unittest2.main()


Mime
View raw message