Repository: incubator-hawq
Updated Branches:
  refs/heads/master 84dd4d4b2 -> 80e25b468


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py 
b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py
new file mode 100644
index 0000000..a6dc16c
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py
@@ -0,0 +1,416 @@
+import sys
+import textwrap
+from StringIO import StringIO
+
+import unittest2
+
+
+class Test_TestResult(unittest2.TestCase):
+    # Note: there are not separate tests for TestResult.wasSuccessful(),
+    # TestResult.errors, TestResult.failures, TestResult.testsRun or
+    # TestResult.shouldStop because these only have meaning in terms of
+    # other TestResult methods.
+    #
+    # Accordingly, tests for the aforenamed attributes are incorporated
+    # in with the tests for the defining methods.
+    ################################################################
+
+    def test_init(self):
+        result = unittest2.TestResult()
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(result.shouldStop, False)
+        self.assertIsNone(result._stdout_buffer)
+        self.assertIsNone(result._stderr_buffer)
+
+    # "This method can be called to signal that the set of tests being
+    # run should be aborted by setting the TestResult's shouldStop
+    # attribute to True."
+    def test_stop(self):
+        result = unittest2.TestResult()
+
+        result.stop()
+
+        self.assertEqual(result.shouldStop, True)
+
+    # "Called when the test case test is about to be run. The default
+    # implementation simply increments the instance's testsRun counter."
+    def test_startTest(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        result.stopTest(test)
+
+    # "Called after the test case test has been executed, regardless of
+    # the outcome. The default implementation does nothing."
+    def test_stopTest(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        result.stopTest(test)
+
+        # Same tests as above; make sure nothing has changed
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+    # "Called before and after tests are run. The default implementation does 
nothing."
+    def test_startTestRun_stopTestRun(self):
+        result = unittest2.TestResult()
+        result.startTestRun()
+        result.stopTestRun()
+
+    # "addSuccess(test)"
+    # ...
+    # "Called when the test case test succeeds"
+    # ...
+    # "wasSuccessful() - Returns True if all tests run so far have passed,
+    # otherwise returns False"
+    # ...
+    # "testsRun - The total number of tests run so far."
+    # ...
+    # "errors - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test which raised an
+    # unexpected exception. Contains formatted
+    # tracebacks instead of sys.exc_info() results."
+    # ...
+    # "failures - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test where a failure was
+    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+    # methods. Contains formatted tracebacks instead
+    # of sys.exc_info() results."
+    def test_addSuccess(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+        result.addSuccess(test)
+        result.stopTest(test)
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+    # "addFailure(test, err)"
+    # ...
+    # "Called when the test case test signals a failure. err is a tuple of
+    # the form returned by sys.exc_info(): (type, value, traceback)"
+    # ...
+    # "wasSuccessful() - Returns True if all tests run so far have passed,
+    # otherwise returns False"
+    # ...
+    # "testsRun - The total number of tests run so far."
+    # ...
+    # "errors - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test which raised an
+    # unexpected exception. Contains formatted
+    # tracebacks instead of sys.exc_info() results."
+    # ...
+    # "failures - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test where a failure was
+    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+    # methods. Contains formatted tracebacks instead
+    # of sys.exc_info() results."
+    def test_addFailure(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+        try:
+            test.fail("foo")
+        except:
+            exc_info_tuple = sys.exc_info()
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+        result.addFailure(test, exc_info_tuple)
+        result.stopTest(test)
+
+        self.assertFalse(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 1)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        test_case, formatted_exc = result.failures[0]
+        self.assertTrue(test_case is test)
+        self.assertIsInstance(formatted_exc, str)
+
+    # "addError(test, err)"
+    # ...
+    # "Called when the test case test raises an unexpected exception err
+    # is a tuple of the form returned by sys.exc_info():
+    # (type, value, traceback)"
+    # ...
+    # "wasSuccessful() - Returns True if all tests run so far have passed,
+    # otherwise returns False"
+    # ...
+    # "testsRun - The total number of tests run so far."
+    # ...
+    # "errors - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test which raised an
+    # unexpected exception. Contains formatted
+    # tracebacks instead of sys.exc_info() results."
+    # ...
+    # "failures - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test where a failure was
+    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+    # methods. Contains formatted tracebacks instead
+    # of sys.exc_info() results."
+    def test_addError(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+        try:
+            raise TypeError()
+        except:
+            exc_info_tuple = sys.exc_info()
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+        result.addError(test, exc_info_tuple)
+        result.stopTest(test)
+
+        self.assertFalse(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 1)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        test_case, formatted_exc = result.errors[0]
+        self.assertTrue(test_case is test)
+        self.assertIsInstance(formatted_exc, str)
+
+    def testGetDescriptionWithoutDocstring(self):
+        result = unittest2.TextTestResult(None, True, 1)
+        self.assertEqual(
+                result.getDescription(self),
+                'testGetDescriptionWithoutDocstring (' + __name__ +
+                '.Test_TestResult)')
+
+    def testGetDescriptionWithOneLineDocstring(self):
+        """Tests getDescription() for a method with a docstring."""
+        result = unittest2.TextTestResult(None, True, 1)
+        self.assertEqual(
+                result.getDescription(self),
+               ('testGetDescriptionWithOneLineDocstring '
+                '(' + __name__ + '.Test_TestResult)\n'
+                'Tests getDescription() for a method with a docstring.'))
+
+    def testGetDescriptionWithMultiLineDocstring(self):
+        """Tests getDescription() for a method with a longer docstring.
+        The second line of the docstring.
+        """
+        result = unittest2.TextTestResult(None, True, 1)
+        self.assertEqual(
+                result.getDescription(self),
+               ('testGetDescriptionWithMultiLineDocstring '
+                '(' + __name__ + '.Test_TestResult)\n'
+                'Tests getDescription() for a method with a longer '
+                'docstring.'))
+
+    def testStackFrameTrimming(self):
+        class Frame(object):
+            class tb_frame(object):
+                f_globals = {}
+        result = unittest2.TestResult()
+        self.assertFalse(result._is_relevant_tb_level(Frame))
+        
+        Frame.tb_frame.f_globals['__unittest'] = True
+        self.assertTrue(result._is_relevant_tb_level(Frame))
+
+    def testFailFast(self):
+        result = unittest2.TestResult()
+        result._exc_info_to_string = lambda *_: ''
+        result.failfast = True
+        result.addError(None, None)
+        self.assertTrue(result.shouldStop)
+
+        result = unittest2.TestResult()
+        result._exc_info_to_string = lambda *_: ''
+        result.failfast = True
+        result.addFailure(None, None)
+        self.assertTrue(result.shouldStop)
+
+        result = unittest2.TestResult()
+        result._exc_info_to_string = lambda *_: ''
+        result.failfast = True
+        result.addUnexpectedSuccess(None)
+        self.assertTrue(result.shouldStop)
+
+    def testFailFastSetByRunner(self):
+        runner = unittest2.TextTestRunner(stream=StringIO(), failfast=True)
+        self.testRan = False
+        def test(result):
+            self.testRan = True
+            self.assertTrue(result.failfast)
+        runner.run(test)
+        self.assertTrue(self.testRan)
+
+
+class TestOutputBuffering(unittest2.TestCase):
+
+    def setUp(self):
+        self._real_out = sys.stdout
+        self._real_err = sys.stderr
+
+    def tearDown(self):
+        sys.stdout = self._real_out
+        sys.stderr = self._real_err
+
+    def testBufferOutputOff(self):
+        real_out = self._real_out
+        real_err = self._real_err
+        
+        result = unittest2.TestResult()
+        self.assertFalse(result.buffer)
+    
+        self.assertIs(real_out, sys.stdout)
+        self.assertIs(real_err, sys.stderr)
+        
+        result.startTest(self)
+        
+        self.assertIs(real_out, sys.stdout)
+        self.assertIs(real_err, sys.stderr)
+
+    def testBufferOutputStartTestAddSuccess(self):
+        real_out = self._real_out
+        real_err = self._real_err
+        
+        result = unittest2.TestResult()
+        self.assertFalse(result.buffer)
+        
+        result.buffer = True
+    
+        self.assertIs(real_out, sys.stdout)
+        self.assertIs(real_err, sys.stderr)
+        
+        result.startTest(self)
+        
+        self.assertIsNot(real_out, sys.stdout)
+        self.assertIsNot(real_err, sys.stderr)
+        self.assertIsInstance(sys.stdout, StringIO)
+        self.assertIsInstance(sys.stderr, StringIO)
+        self.assertIsNot(sys.stdout, sys.stderr)
+        
+        out_stream = sys.stdout
+        err_stream = sys.stderr
+        
+        result._original_stdout = StringIO()
+        result._original_stderr = StringIO()
+        
+        print 'foo'
+        print >> sys.stderr, 'bar'
+        
+        self.assertEqual(out_stream.getvalue(), 'foo\n')
+        self.assertEqual(err_stream.getvalue(), 'bar\n')
+        
+        self.assertEqual(result._original_stdout.getvalue(), '')
+        self.assertEqual(result._original_stderr.getvalue(), '')
+        
+        result.addSuccess(self)
+        result.stopTest(self)
+        
+        self.assertIs(sys.stdout, result._original_stdout)
+        self.assertIs(sys.stderr, result._original_stderr)
+        
+        self.assertEqual(result._original_stdout.getvalue(), '')
+        self.assertEqual(result._original_stderr.getvalue(), '')
+        
+        self.assertEqual(out_stream.getvalue(), '')
+        self.assertEqual(err_stream.getvalue(), '')
+        
+
+    def getStartedResult(self):
+        result = unittest2.TestResult()
+        result.buffer = True
+        result.startTest(self)
+        return result
+
+    def testBufferOutputAddErrorOrFailure(self):
+        for message_attr, add_attr, include_error in [
+            ('errors', 'addError', True), 
+            ('failures', 'addFailure', False),
+            ('errors', 'addError', True), 
+            ('failures', 'addFailure', False)
+        ]:
+            result = self.getStartedResult()
+            result._original_stderr = StringIO()
+            result._original_stdout = StringIO()
+            
+            print >> sys.stdout, 'foo'
+            if include_error:
+                print >> sys.stderr, 'bar'
+            
+            addFunction = getattr(result, add_attr)
+            addFunction(self, (None, None, None))
+            result.stopTest(self)
+            
+            result_list = getattr(result, message_attr)
+            self.assertEqual(len(result_list), 1)
+            
+            test, message = result_list[0]
+            expectedOutMessage = textwrap.dedent("""
+                Stdout:
+                foo
+            """)
+            expectedErrMessage = ''
+            if include_error:
+                expectedErrMessage = textwrap.dedent("""
+                Stderr:
+                bar
+            """)
+            expectedFullMessage = 'None\n%s%s' % (expectedOutMessage, 
expectedErrMessage)
+
+            self.assertIs(test, self)
+            self.assertEqual(result._original_stdout.getvalue(), 
expectedOutMessage)
+            self.assertEqual(result._original_stderr.getvalue(), 
expectedErrMessage)
+            self.assertMultiLineEqual(message, expectedFullMessage)
+        
+        
+
+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_runner.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_runner.py 
b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_runner.py
new file mode 100644
index 0000000..38b39ef
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_runner.py
@@ -0,0 +1,129 @@
+import pickle
+
+from cStringIO import StringIO
+from unittest2.test.support import LoggingResult, OldTestResult
+
+import unittest2
+
+
+class Test_TextTestRunner(unittest2.TestCase):
+    """Tests for TextTestRunner."""
+
+    def test_init(self):
+        runner = unittest2.TextTestRunner()
+        self.assertFalse(runner.failfast)
+        self.assertFalse(runner.buffer)
+        self.assertEqual(runner.verbosity, 1)
+        self.assertTrue(runner.descriptions)
+        self.assertEqual(runner.resultclass, unittest2.TextTestResult)
+
+
+    def testBufferAndFailfast(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        result = unittest2.TestResult()
+        runner = unittest2.TextTestRunner(stream=StringIO(), failfast=True,
+                                           buffer=True)
+        # Use our result object
+        runner._makeResult = lambda: result
+        runner.run(Test('testFoo'))
+        
+        self.assertTrue(result.failfast)
+        self.assertTrue(result.buffer)
+
+    def testRunnerRegistersResult(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        originalRegisterResult = unittest2.runner.registerResult
+        def cleanup():
+            unittest2.runner.registerResult = originalRegisterResult
+        self.addCleanup(cleanup)
+        
+        result = unittest2.TestResult()
+        runner = unittest2.TextTestRunner(stream=StringIO())
+        # Use our result object
+        runner._makeResult = lambda: result
+        
+        self.wasRegistered = 0
+        def fakeRegisterResult(thisResult):
+            self.wasRegistered += 1
+            self.assertEqual(thisResult, result)
+        unittest2.runner.registerResult = fakeRegisterResult
+        
+        runner.run(unittest2.TestSuite())
+        self.assertEqual(self.wasRegistered, 1)
+        
+    def test_works_with_result_without_startTestRun_stopTestRun(self):
+        class OldTextResult(OldTestResult):
+            def __init__(self, *_):
+                super(OldTextResult, self).__init__()
+            separator2 = ''
+            def printErrors(self):
+                pass
+
+        runner = unittest2.TextTestRunner(stream=StringIO(), 
+                                          resultclass=OldTextResult)
+        runner.run(unittest2.TestSuite())
+
+    def test_startTestRun_stopTestRun_called(self):
+        class LoggingTextResult(LoggingResult):
+            separator2 = ''
+            def printErrors(self):
+                pass
+
+        class LoggingRunner(unittest2.TextTestRunner):
+            def __init__(self, events):
+                super(LoggingRunner, self).__init__(StringIO())
+                self._events = events
+
+            def _makeResult(self):
+                return LoggingTextResult(self._events)
+
+        events = []
+        runner = LoggingRunner(events)
+        runner.run(unittest2.TestSuite())
+        expected = ['startTestRun', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    def test_pickle_unpickle(self):
+        # Issue #7197: a TextTestRunner should be (un)pickleable. This is
+        # required by test_multiprocessing under Windows (in verbose mode).
+        import StringIO
+        # cStringIO objects are not pickleable, but StringIO objects are.
+        stream = StringIO.StringIO("foo")
+        runner = unittest2.TextTestRunner(stream)
+        for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
+            s = pickle.dumps(runner, protocol=protocol)
+            obj = pickle.loads(s)
+            # StringIO objects never compare equal, a cheap test instead.
+            self.assertEqual(obj.stream.getvalue(), stream.getvalue())
+
+    def test_resultclass(self):
+        def MockResultClass(*args):
+            return args
+        STREAM = object()
+        DESCRIPTIONS = object()
+        VERBOSITY = object()
+        runner = unittest2.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY,
+                                         resultclass=MockResultClass)
+        self.assertEqual(runner.resultclass, MockResultClass)
+
+        expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
+        self.assertEqual(runner._makeResult(), expectedresult)
+
+
+    def test_oldresult(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        runner = unittest2.TextTestRunner(resultclass=OldTestResult,
+                                          stream=StringIO())
+        # This will raise an exception if TextTestRunner can't handle old
+        # test result objects
+        runner.run(Test('testFoo'))
+
+
+if __name__ == '__main__':
+    unittest2.main()
\ 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/test_setups.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_setups.py 
b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_setups.py
new file mode 100644
index 0000000..55c7f57
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_setups.py
@@ -0,0 +1,502 @@
+import sys
+
+from cStringIO import StringIO
+
+import unittest2
+from unittest2.test.support import resultFactory
+
+
+class TestSetups(unittest2.TestCase):
+    
+    def getRunner(self):
+        return unittest2.TextTestRunner(resultclass=resultFactory,
+                                          stream=StringIO())
+    def runTests(self, *cases):
+        suite = unittest2.TestSuite()
+        for case in cases:
+            tests = unittest2.defaultTestLoader.loadTestsFromTestCase(case)
+            suite.addTests(tests)
+        
+        runner = self.getRunner()
+        
+        # creating a nested suite exposes some potential bugs
+        realSuite = unittest2.TestSuite()
+        realSuite.addTest(suite)
+        # adding empty suites to the end exposes potential bugs
+        suite.addTest(unittest2.TestSuite())
+        realSuite.addTest(unittest2.TestSuite())
+        return runner.run(realSuite)
+    
+    def test_setup_class(self):
+        class Test(unittest2.TestCase):
+            setUpCalled = 0
+            @classmethod
+            def setUpClass(cls):
+                Test.setUpCalled += 1
+                unittest2.TestCase.setUpClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        result = self.runTests(Test)
+        
+        self.assertEqual(Test.setUpCalled, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+
+    def test_teardown_class(self):
+        class Test(unittest2.TestCase):
+            tearDownCalled = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test.tearDownCalled += 1
+                unittest2.TestCase.tearDownClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        result = self.runTests(Test)
+        
+        self.assertEqual(Test.tearDownCalled, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+    
+    def test_teardown_class_two_classes(self):
+        class Test(unittest2.TestCase):
+            tearDownCalled = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test.tearDownCalled += 1
+                unittest2.TestCase.tearDownClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        class Test2(unittest2.TestCase):
+            tearDownCalled = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test2.tearDownCalled += 1
+                unittest2.TestCase.tearDownClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        result = self.runTests(Test, Test2)
+        
+        self.assertEqual(Test.tearDownCalled, 1)
+        self.assertEqual(Test2.tearDownCalled, 1)
+        self.assertEqual(result.testsRun, 4)
+        self.assertEqual(len(result.errors), 0)
+
+    def test_error_in_setupclass(self):
+        class BrokenTest(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        result = self.runTests(BrokenTest)
+        
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 1)
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 
+                    'setUpClass (%s.BrokenTest)' % __name__)
+
+    def test_error_in_teardown_class(self):
+        class Test(unittest2.TestCase):
+            tornDown = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test.tornDown += 1
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        class Test2(unittest2.TestCase):
+            tornDown = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test2.tornDown += 1
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        result = self.runTests(Test, Test2)
+        self.assertEqual(result.testsRun, 4)
+        self.assertEqual(len(result.errors), 2)
+        self.assertEqual(Test.tornDown, 1)
+        self.assertEqual(Test2.tornDown, 1)
+        
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 
+                    'tearDownClass (%s.Test)' % __name__)
+
+    def test_class_not_torndown_when_setup_fails(self):
+        class Test(unittest2.TestCase):
+            tornDown = False
+            @classmethod
+            def setUpClass(cls):
+                raise TypeError
+            @classmethod
+            def tearDownClass(cls):
+                Test.tornDown = True
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+
+        self.runTests(Test)
+        self.assertFalse(Test.tornDown)
+    
+    def test_class_not_setup_or_torndown_when_skipped(self):
+        class Test(unittest2.TestCase):
+            classSetUp = False
+            tornDown = False
+            @classmethod
+            def setUpClass(cls):
+                Test.classSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                Test.tornDown = True
+            def test_one(self):
+                pass
+
+        Test = unittest2.skip("hop")(Test)
+        self.runTests(Test)
+        self.assertFalse(Test.classSetUp)
+        self.assertFalse(Test.tornDown)
+
+    def test_setup_teardown_order_with_pathological_suite(self):
+        results = []
+        
+        class Module1(object):
+            @staticmethod
+            def setUpModule():
+                results.append('Module1.setUpModule')
+            @staticmethod
+            def tearDownModule():
+                results.append('Module1.tearDownModule')
+    
+        class Module2(object):
+            @staticmethod
+            def setUpModule():
+                results.append('Module2.setUpModule')
+            @staticmethod
+            def tearDownModule():
+                results.append('Module2.tearDownModule')
+                
+        class Test1(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                results.append('setup 1')
+            @classmethod
+            def tearDownClass(cls):
+                results.append('teardown 1')
+            def testOne(self):
+                results.append('Test1.testOne')
+            def testTwo(self):
+                results.append('Test1.testTwo')
+            
+        class Test2(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                results.append('setup 2')
+            @classmethod
+            def tearDownClass(cls):
+                results.append('teardown 2')
+            def testOne(self):
+                results.append('Test2.testOne')
+            def testTwo(self):
+                results.append('Test2.testTwo')
+            
+        class Test3(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                results.append('setup 3')
+            @classmethod
+            def tearDownClass(cls):
+                results.append('teardown 3')
+            def testOne(self):
+                results.append('Test3.testOne')
+            def testTwo(self):
+                results.append('Test3.testTwo')
+        
+        Test1.__module__ = Test2.__module__ = 'Module'
+        Test3.__module__ = 'Module2'
+        sys.modules['Module'] = Module1
+        sys.modules['Module2'] = Module2
+        
+        first = unittest2.TestSuite((Test1('testOne'),))
+        second = unittest2.TestSuite((Test1('testTwo'),))
+        third = unittest2.TestSuite((Test2('testOne'),))
+        fourth = unittest2.TestSuite((Test2('testTwo'),))
+        fifth = unittest2.TestSuite((Test3('testOne'),))
+        sixth = unittest2.TestSuite((Test3('testTwo'),))
+        suite = unittest2.TestSuite((first, second, third, fourth, fifth, 
sixth))
+        
+        runner = self.getRunner()
+        result = runner.run(suite)
+        self.assertEqual(result.testsRun, 6)
+        self.assertEqual(len(result.errors), 0)
+
+        self.assertEqual(results,
+                         ['Module1.setUpModule', 'setup 1', 
+                          'Test1.testOne', 'Test1.testTwo', 'teardown 1',
+                          'setup 2', 'Test2.testOne', 'Test2.testTwo', 
+                          'teardown 2', 'Module1.tearDownModule',
+                          'Module2.setUpModule', 'setup 3',
+                          'Test3.testOne', 'Test3.testTwo', 
+                          'teardown 3', 'Module2.tearDownModule'])
+        
+    def test_setup_module(self):
+        class Module(object):
+            moduleSetup = 0
+            @staticmethod
+            def setUpModule():
+                Module.moduleSetup += 1
+        
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test)
+        self.assertEqual(Module.moduleSetup, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+    
+    def test_error_in_setup_module(self):
+        class Module(object):
+            moduleSetup = 0
+            moduleTornDown = 0
+            @staticmethod
+            def setUpModule():
+                Module.moduleSetup += 1
+                raise TypeError('foo')
+            @staticmethod
+            def tearDownModule():
+                Module.moduleTornDown += 1
+        
+        class Test(unittest2.TestCase):
+            classSetUp = False
+            classTornDown = False
+            @classmethod
+            def setUpClass(cls):
+                Test.classSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                Test.classTornDown = True
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        class Test2(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        Test2.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test, Test2)
+        self.assertEqual(Module.moduleSetup, 1)
+        self.assertEqual(Module.moduleTornDown, 0)
+        self.assertEqual(result.testsRun, 0)
+        self.assertFalse(Test.classSetUp)
+        self.assertFalse(Test.classTornDown)
+        self.assertEqual(len(result.errors), 1)
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 'setUpModule (Module)')
+        
+    def test_testcase_with_missing_module(self):
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        sys.modules.pop('Module', None)
+        
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 2)
+
+    def test_teardown_module(self):
+        class Module(object):
+            moduleTornDown = 0
+            @staticmethod
+            def tearDownModule():
+                Module.moduleTornDown += 1
+        
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test)
+        self.assertEqual(Module.moduleTornDown, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+
+    def test_error_in_teardown_module(self):
+        class Module(object):
+            moduleTornDown = 0
+            @staticmethod
+            def tearDownModule():
+                Module.moduleTornDown += 1
+                raise TypeError('foo')
+        
+        class Test(unittest2.TestCase):
+            classSetUp = False
+            classTornDown = False
+            @classmethod
+            def setUpClass(cls):
+                Test.classSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                Test.classTornDown = True
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        class Test2(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        Test2.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test, Test2)
+        self.assertEqual(Module.moduleTornDown, 1)
+        self.assertEqual(result.testsRun, 4)
+        self.assertTrue(Test.classSetUp)
+        self.assertTrue(Test.classTornDown)
+        self.assertEqual(len(result.errors), 1)
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 'tearDownModule (Module)')
+
+    def test_skiptest_in_setupclass(self):
+        class Test(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                raise unittest2.SkipTest('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.skipped), 1)
+        skipped = result.skipped[0][0]
+        self.assertEqual(str(skipped), 'setUpClass (%s.Test)' % __name__)
+
+    def test_skiptest_in_setupmodule(self):
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                raise unittest2.SkipTest('foo')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.skipped), 1)
+        skipped = result.skipped[0][0]
+        self.assertEqual(str(skipped), 'setUpModule (Module)')
+
+    def test_suite_debug_executes_setups_and_teardowns(self):
+        ordering = []
+
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                ordering.append('setUpModule')
+            @staticmethod
+            def tearDownModule():
+                ordering.append('tearDownModule')
+
+        class Test(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                ordering.append('setUpClass')
+            @classmethod
+            def tearDownClass(cls):
+                ordering.append('tearDownClass')
+            def test_something(self):
+                ordering.append('test_something')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        suite = unittest2.defaultTestLoader.loadTestsFromTestCase(Test)
+        suite.debug()
+        expectedOrder = ['setUpModule', 'setUpClass', 'test_something', 
'tearDownClass', 'tearDownModule']
+        self.assertEqual(ordering, expectedOrder)
+
+    def test_suite_debug_propagates_exceptions(self):
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                if phase == 0:
+                    raise Exception('setUpModule')
+            @staticmethod
+            def tearDownModule():
+                if phase == 1:
+                    raise Exception('tearDownModule')
+
+        class Test(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                if phase == 2:
+                    raise Exception('setUpClass')
+            @classmethod
+            def tearDownClass(cls):
+                if phase == 3:
+                    raise Exception('tearDownClass')
+            def test_something(self):
+                if phase == 4:
+                    raise Exception('test_something')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        _suite = unittest2.defaultTestLoader.loadTestsFromTestCase(Test)
+        suite = unittest2.TestSuite()
+        
+        # nesting a suite again exposes a bug in the initial implementation
+        suite.addTest(_suite)
+        messages = ('setUpModule', 'tearDownModule', 'setUpClass', 
'tearDownClass', 'test_something')
+        for phase, msg in enumerate(messages):
+            self.assertRaisesRegexp(Exception, msg, suite.debug)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py
----------------------------------------------------------------------
diff --git 
a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py 
b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py
new file mode 100644
index 0000000..9555b9f
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py
@@ -0,0 +1,143 @@
+from unittest2.test.support import LoggingResult
+
+import unittest2
+
+
+class Test_TestSkipping(unittest2.TestCase):
+
+    def test_skipping(self):
+        class Foo(unittest2.TestCase):
+            def test_skip_me(self):
+                self.skipTest("skip")
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_skip_me")
+        test.run(result)
+        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
+        self.assertEqual(result.skipped, [(test, "skip")])
+
+        # Try letting setUp skip the test now.
+        class Foo(unittest2.TestCase):
+            def setUp(self):
+                self.skipTest("testing")
+            def test_nothing(self): pass
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_nothing")
+        test.run(result)
+        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
+        self.assertEqual(result.skipped, [(test, "testing")])
+        self.assertEqual(result.testsRun, 1)
+
+    def test_skipping_decorators(self):
+        op_table = ((unittest2.skipUnless, False, True),
+                    (unittest2.skipIf, True, False))
+        for deco, do_skip, dont_skip in op_table:
+            class Foo(unittest2.TestCase):
+                @deco(do_skip, "testing")
+                def test_skip(self): 
+                    pass
+
+                @deco(dont_skip, "testing")
+                def test_dont_skip(self): 
+                    pass
+            
+            test_do_skip = Foo("test_skip")
+            test_dont_skip = Foo("test_dont_skip")
+            suite = unittest2.TestSuite([test_do_skip, test_dont_skip])
+            events = []
+            result = LoggingResult(events)
+            suite.run(result)
+            self.assertEqual(len(result.skipped), 1)
+            expected = ['startTest', 'addSkip', 'stopTest',
+                        'startTest', 'addSuccess', 'stopTest']
+            self.assertEqual(events, expected)
+            self.assertEqual(result.testsRun, 2)
+            self.assertEqual(result.skipped, [(test_do_skip, "testing")])
+            self.assertTrue(result.wasSuccessful())
+        
+    def test_skip_class(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                record.append(1)
+        
+        # was originally a class decorator...
+        Foo = unittest2.skip("testing")(Foo)
+        record = []
+        result = unittest2.TestResult()
+        test = Foo("test_1")
+        suite = unittest2.TestSuite([test])
+        suite.run(result)
+        self.assertEqual(result.skipped, [(test, "testing")])
+        self.assertEqual(record, [])
+
+    def test_expected_failure(self):
+        class Foo(unittest2.TestCase):
+            @unittest2.expectedFailure
+            def test_die(self):
+                self.fail("help me!")
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_die")
+        test.run(result)
+        self.assertEqual(events,
+                         ['startTest', 'addExpectedFailure', 'stopTest'])
+        self.assertEqual(result.expectedFailures[0][0], test)
+        self.assertTrue(result.wasSuccessful())
+
+    def test_unexpected_success(self):
+        class Foo(unittest2.TestCase):
+            @unittest2.expectedFailure
+            def test_die(self):
+                pass
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_die")
+        test.run(result)
+        self.assertEqual(events,
+                         ['startTest', 'addUnexpectedSuccess', 'stopTest'])
+        self.assertFalse(result.failures)
+        self.assertEqual(result.unexpectedSuccesses, [test])
+        self.assertTrue(result.wasSuccessful())
+
+    def test_skip_doesnt_run_setup(self):
+        class Foo(unittest2.TestCase):
+            wasSetUp = False
+            wasTornDown = False
+            def setUp(self):
+                Foo.wasSetUp = True
+            def tornDown(self):
+                Foo.wasTornDown = True
+            @unittest2.skip('testing')
+            def test_1(self):
+                pass
+        
+        result = unittest2.TestResult()
+        test = Foo("test_1")
+        suite = unittest2.TestSuite([test])
+        suite.run(result)
+        self.assertEqual(result.skipped, [(test, "testing")])
+        self.assertFalse(Foo.wasSetUp)
+        self.assertFalse(Foo.wasTornDown)
+    
+    def test_decorated_skip(self):
+        def decorator(func):
+            def inner(*a):
+                return func(*a)
+            return inner
+        
+        class Foo(unittest2.TestCase):
+            @decorator
+            @unittest2.skip('testing')
+            def test_1(self):
+                pass
+        
+        result = unittest2.TestResult()
+        test = Foo("test_1")
+        suite = unittest2.TestSuite([test])
+        suite.run(result)
+        self.assertEqual(result.skipped, [(test, "testing")])
+
+
+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_suite.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_suite.py 
b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_suite.py
new file mode 100644
index 0000000..64a72bb
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_suite.py
@@ -0,0 +1,341 @@
+from unittest2.test.support import EqualityMixin, LoggingResult
+
+import sys
+import unittest2
+
+class Test(object):
+    class Foo(unittest2.TestCase):
+        def test_1(self): pass
+        def test_2(self): pass
+        def test_3(self): pass
+        def runTest(self): pass
+
+def _mk_TestSuite(*names):
+    return unittest2.TestSuite(Test.Foo(n) for n in names)
+
+
+class Test_TestSuite(unittest2.TestCase, EqualityMixin):
+
+    ### Set up attributes needed by inherited tests
+    ################################################################
+
+    # Used by EqualityMixin.test_eq
+    eq_pairs = [(unittest2.TestSuite(), unittest2.TestSuite()),
+                (unittest2.TestSuite(), unittest2.TestSuite([])),
+                (_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))]
+
+    # Used by EqualityMixin.test_ne
+    ne_pairs = [(unittest2.TestSuite(), _mk_TestSuite('test_1')),
+                (unittest2.TestSuite([]), _mk_TestSuite('test_1')),
+                (_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 
'test_3')),
+                (_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))]
+
+    ################################################################
+    ### /Set up attributes needed by inherited tests
+
+    ### Tests for TestSuite.__init__
+    ################################################################
+
+    # "class TestSuite([tests])"
+    #
+    # The tests iterable should be optional
+    def test_init__tests_optional(self):
+        suite = unittest2.TestSuite()
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "class TestSuite([tests])"
+    # ...
+    # "If tests is given, it must be an iterable of individual test cases
+    # or other test suites that will be used to build the suite initially"
+    #
+    # TestSuite should deal with empty tests iterables by allowing the
+    # creation of an empty suite
+    def test_init__empty_tests(self):
+        suite = unittest2.TestSuite([])
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "class TestSuite([tests])"
+    # ...
+    # "If tests is given, it must be an iterable of individual test cases
+    # or other test suites that will be used to build the suite initially"
+    #
+    # TestSuite should allow any iterable to provide tests
+    def test_init__tests_from_any_iterable(self):
+        def tests():
+            yield unittest2.FunctionTestCase(lambda: None)
+            yield unittest2.FunctionTestCase(lambda: None)
+
+        suite_1 = unittest2.TestSuite(tests())
+        self.assertEqual(suite_1.countTestCases(), 2)
+
+        suite_2 = unittest2.TestSuite(suite_1)
+        self.assertEqual(suite_2.countTestCases(), 2)
+
+        suite_3 = unittest2.TestSuite(set(suite_1))
+        self.assertEqual(suite_3.countTestCases(), 2)
+
+    # "class TestSuite([tests])"
+    # ...
+    # "If tests is given, it must be an iterable of individual test cases
+    # or other test suites that will be used to build the suite initially"
+    #
+    # Does TestSuite() also allow other TestSuite() instances to be present
+    # in the tests iterable?
+    def test_init__TestSuite_instances_in_tests(self):
+        def tests():
+            ftc = unittest2.FunctionTestCase(lambda: None)
+            yield unittest2.TestSuite([ftc])
+            yield unittest2.FunctionTestCase(lambda: None)
+
+        suite = unittest2.TestSuite(tests())
+        self.assertEqual(suite.countTestCases(), 2)
+
+    ################################################################
+    ### /Tests for TestSuite.__init__
+
+    # Container types should support the iter protocol
+    def test_iter(self):
+        test1 = unittest2.FunctionTestCase(lambda: None)
+        test2 = unittest2.FunctionTestCase(lambda: None)
+        suite = unittest2.TestSuite((test1, test2))
+
+        self.assertEqual(list(suite), [test1, test2])
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    #
+    # Presumably an empty TestSuite returns 0?
+    def test_countTestCases_zero_simple(self):
+        suite = unittest2.TestSuite()
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    #
+    # Presumably an empty TestSuite (even if it contains other empty
+    # TestSuite instances) returns 0?
+    def test_countTestCases_zero_nested(self):
+        class Test1(unittest2.TestCase):
+            def test(self):
+                pass
+
+        suite = unittest2.TestSuite([unittest2.TestSuite()])
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    def test_countTestCases_simple(self):
+        test1 = unittest2.FunctionTestCase(lambda: None)
+        test2 = unittest2.FunctionTestCase(lambda: None)
+        suite = unittest2.TestSuite((test1, test2))
+
+        self.assertEqual(suite.countTestCases(), 2)
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    #
+    # Make sure this holds for nested TestSuite instances, too
+    def test_countTestCases_nested(self):
+        class Test1(unittest2.TestCase):
+            def test1(self): pass
+            def test2(self): pass
+
+        test2 = unittest2.FunctionTestCase(lambda: None)
+        test3 = unittest2.FunctionTestCase(lambda: None)
+        child = unittest2.TestSuite((Test1('test2'), test2))
+        parent = unittest2.TestSuite((test3, child, Test1('test1')))
+
+        self.assertEqual(parent.countTestCases(), 4)
+
+    # "Run the tests associated with this suite, collecting the result into
+    # the test result object passed as result."
+    #
+    # And if there are no tests? What then?
+    def test_run__empty_suite(self):
+        events = []
+        result = LoggingResult(events)
+
+        suite = unittest2.TestSuite()
+
+        suite.run(result)
+
+        self.assertEqual(events, [])
+
+    # "Note that unlike TestCase.run(), TestSuite.run() requires the
+    # "result object to be passed in."
+    def test_run__requires_result(self):
+        suite = unittest2.TestSuite()
+
+        try:
+            suite.run()
+        except TypeError:
+            pass
+        else:
+            self.fail("Failed to raise TypeError")
+
+    # "Run the tests associated with this suite, collecting the result into
+    # the test result object passed as result."
+    def test_run(self):
+        events = []
+        result = LoggingResult(events)
+
+        class LoggingCase(unittest2.TestCase):
+            def run(self, result):
+                events.append('run %s' % self._testMethodName)
+
+            def test1(self): pass
+            def test2(self): pass
+
+        tests = [LoggingCase('test1'), LoggingCase('test2')]
+
+        unittest2.TestSuite(tests).run(result)
+
+        self.assertEqual(events, ['run test1', 'run test2'])
+
+    # "Add a TestCase ... to the suite"
+    def test_addTest__TestCase(self):
+        class Foo(unittest2.TestCase):
+            def test(self): pass
+
+        test = Foo('test')
+        suite = unittest2.TestSuite()
+
+        suite.addTest(test)
+
+        self.assertEqual(suite.countTestCases(), 1)
+        self.assertEqual(list(suite), [test])
+
+    # "Add a ... TestSuite to the suite"
+    def test_addTest__TestSuite(self):
+        class Foo(unittest2.TestCase):
+            def test(self): pass
+
+        suite_2 = unittest2.TestSuite([Foo('test')])
+
+        suite = unittest2.TestSuite()
+        suite.addTest(suite_2)
+
+        self.assertEqual(suite.countTestCases(), 1)
+        self.assertEqual(list(suite), [suite_2])
+
+    # "Add all the tests from an iterable of TestCase and TestSuite
+    # instances to this test suite."
+    #
+    # "This is equivalent to iterating over tests, calling addTest() for
+    # each element"
+    def test_addTests(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+
+        test_1 = Foo('test_1')
+        test_2 = Foo('test_2')
+        inner_suite = unittest2.TestSuite([test_2])
+
+        def gen():
+            yield test_1
+            yield test_2
+            yield inner_suite
+
+        suite_1 = unittest2.TestSuite()
+        suite_1.addTests(gen())
+
+        self.assertEqual(list(suite_1), list(gen()))
+
+        # "This is equivalent to iterating over tests, calling addTest() for
+        # each element"
+        suite_2 = unittest2.TestSuite()
+        for t in gen():
+            suite_2.addTest(t)
+
+        self.assertEqual(suite_1, suite_2)
+
+    # "Add all the tests from an iterable of TestCase and TestSuite
+    # instances to this test suite."
+    #
+    # What happens if it doesn't get an iterable?
+    def test_addTest__noniterable(self):
+        suite = unittest2.TestSuite()
+
+        try:
+            suite.addTests(5)
+        except TypeError:
+            pass
+        else:
+            self.fail("Failed to raise TypeError")
+
+    def test_addTest__noncallable(self):
+        suite = unittest2.TestSuite()
+        self.assertRaises(TypeError, suite.addTest, 5)
+
+    def test_addTest__casesuiteclass(self):
+        suite = unittest2.TestSuite()
+        self.assertRaises(TypeError, suite.addTest, Test_TestSuite)
+        self.assertRaises(TypeError, suite.addTest, unittest2.TestSuite)
+
+    def test_addTests__string(self):
+        suite = unittest2.TestSuite()
+        self.assertRaises(TypeError, suite.addTests, "foo")
+
+    def test_function_in_suite(self):
+        def f(_):
+            pass
+        suite = unittest2.TestSuite()
+        suite.addTest(f)
+
+        # when the bug is fixed this line will not crash
+        suite.run(unittest2.TestResult())
+
+
+    def test_basetestsuite(self):
+        class Test(unittest2.TestCase):
+            wasSetUp = False
+            wasTornDown = False
+            @classmethod
+            def setUpClass(cls):
+                cls.wasSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                cls.wasTornDown = True
+            def testPass(self):
+                pass
+            def testFail(self):
+                fail
+        class Module(object):
+            wasSetUp = False
+            wasTornDown = False
+            @staticmethod
+            def setUpModule():
+                Module.wasSetUp = True
+            @staticmethod
+            def tearDownModule():
+                Module.wasTornDown = True
+        
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        self.addCleanup(sys.modules.pop, 'Module')
+        
+        suite = unittest2.BaseTestSuite()
+        suite.addTests([Test('testPass'), Test('testFail')])
+        self.assertEqual(suite.countTestCases(), 2)
+
+        result = unittest2.TestResult()
+        suite.run(result)
+        self.assertFalse(Module.wasSetUp)
+        self.assertFalse(Module.wasTornDown)
+        self.assertFalse(Test.wasSetUp)
+        self.assertFalse(Test.wasTornDown)
+        self.assertEqual(len(result.errors), 1)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 2)
+
+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_unittest2_with.py
----------------------------------------------------------------------
diff --git 
a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_unittest2_with.py 
b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_unittest2_with.py
new file mode 100644
index 0000000..6a08b6f
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_unittest2_with.py
@@ -0,0 +1,143 @@
+from __future__ import with_statement
+
+import unittest2
+from unittest2.test.support import OldTestResult, catch_warnings
+
+import warnings
+# needed to enable the deprecation warnings
+warnings.simplefilter('default')
+
+class TestWith(unittest2.TestCase):
+    """Tests that use the with statement live in this
+    module so that all other tests can be run with Python 2.4.
+    """
+
+    def testAssertRaisesExcValue(self):
+        class ExceptionMock(Exception):
+            pass
+
+        def Stub(foo):
+            raise ExceptionMock(foo)
+        v = "particular value"
+
+        ctx = self.assertRaises(ExceptionMock)
+        with ctx:
+            Stub(v)
+        e = ctx.exception
+        self.assertIsInstance(e, ExceptionMock)
+        self.assertEqual(e.args[0], v)
+
+    
+    def test_assertRaises(self):
+        def _raise(e):
+            raise e
+        self.assertRaises(KeyError, _raise, KeyError)
+        self.assertRaises(KeyError, _raise, KeyError("key"))
+        try:
+            self.assertRaises(KeyError, lambda: None)
+        except self.failureException, e:
+            self.assertIn("KeyError not raised", e.args)
+        else:
+            self.fail("assertRaises() didn't fail")
+        try:
+            self.assertRaises(KeyError, _raise, ValueError)
+        except ValueError:
+            pass
+        else:
+            self.fail("assertRaises() didn't let exception pass through")
+        with self.assertRaises(KeyError) as cm:
+            try:
+                raise KeyError
+            except Exception, e:
+                raise
+        self.assertIs(cm.exception, e)
+
+        with self.assertRaises(KeyError):
+            raise KeyError("key")
+        try:
+            with self.assertRaises(KeyError):
+                pass
+        except self.failureException, e:
+            self.assertIn("KeyError not raised", e.args)
+        else:
+            self.fail("assertRaises() didn't fail")
+        try:
+            with self.assertRaises(KeyError):
+                raise ValueError
+        except ValueError:
+            pass
+        else:
+            self.fail("assertRaises() didn't let exception pass through")
+
+    def test_assert_dict_unicode_error(self):
+        with catch_warnings(record=True):
+            # This causes a UnicodeWarning due to its craziness
+            one = ''.join(chr(i) for i in range(255))
+            # this used to cause a UnicodeDecodeError constructing the failure 
msg
+            with self.assertRaises(self.failureException):
+                self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'})
+
+    def test_formatMessage_unicode_error(self):
+        with catch_warnings(record=True):
+            # This causes a UnicodeWarning due to its craziness
+            one = ''.join(chr(i) for i in range(255))
+            # this used to cause a UnicodeDecodeError constructing msg
+            self._formatMessage(one, u'\uFFFD')
+                
+    def assertOldResultWarning(self, test, failures):
+        with catch_warnings(record=True) as log:
+            result = OldTestResult()
+            test.run(result)
+            self.assertEqual(len(result.failures), failures)
+            warning, = log
+            self.assertIs(warning.category, DeprecationWarning)
+
+    def test_old_testresult(self):
+        class Test(unittest2.TestCase):
+            def testSkip(self):
+                self.skipTest('foobar')
+            @unittest2.expectedFailure
+            def testExpectedFail(self):
+                raise TypeError
+            @unittest2.expectedFailure
+            def testUnexpectedSuccess(self):
+                pass
+        
+        for test_name, should_pass in (('testSkip', True), 
+                                       ('testExpectedFail', True), 
+                                       ('testUnexpectedSuccess', False)):
+            test = Test(test_name)
+            self.assertOldResultWarning(test, int(not should_pass))
+        
+    def test_old_testresult_setup(self):
+        class Test(unittest2.TestCase):
+            def setUp(self):
+                self.skipTest('no reason')
+            def testFoo(self):
+                pass
+        self.assertOldResultWarning(Test('testFoo'), 0)
+        
+    def test_old_testresult_class(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        Test = unittest2.skip('no reason')(Test)
+        self.assertOldResultWarning(Test('testFoo'), 0)
+
+    def testPendingDeprecationMethodNames(self):
+        """Test fail* methods pending deprecation, they will warn in 3.2.
+
+        Do not use these methods.  They will go away in 3.3.
+        """
+        with catch_warnings(record=True):
+            self.failIfEqual(3, 5)
+            self.failUnlessEqual(3, 3)
+            self.failUnlessAlmostEqual(2.0, 2.0)
+            self.failIfAlmostEqual(3.0, 5.0)
+            self.failUnless(True)
+            self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam')
+            self.failIf(False)
+
+
+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/util.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/util.py 
b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/util.py
new file mode 100644
index 0000000..c45d008
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/util.py
@@ -0,0 +1,99 @@
+"""Various utility functions."""
+
+__unittest = True
+
+
+_MAX_LENGTH = 80
+def safe_repr(obj, short=False):
+    try:
+        result = repr(obj)
+    except Exception:
+        result = object.__repr__(obj)
+    if not short or len(result) < _MAX_LENGTH:
+        return result
+    return result[:_MAX_LENGTH] + ' [truncated]...'
+
+def safe_str(obj):
+    try:
+        return str(obj)
+    except Exception:
+        return object.__str__(obj)
+
+def strclass(cls):
+    return "%s.%s" % (cls.__module__, cls.__name__)
+
+def sorted_list_difference(expected, actual):
+    """Finds elements in only one or the other of two, sorted input lists.
+
+    Returns a two-element tuple of lists.    The first list contains those
+    elements in the "expected" list but not in the "actual" list, and the
+    second contains those elements in the "actual" list but not in the
+    "expected" list.    Duplicate elements in either input list are ignored.
+    """
+    i = j = 0
+    missing = []
+    unexpected = []
+    while True:
+        try:
+            e = expected[i]
+            a = actual[j]
+            if e < a:
+                missing.append(e)
+                i += 1
+                while expected[i] == e:
+                    i += 1
+            elif e > a:
+                unexpected.append(a)
+                j += 1
+                while actual[j] == a:
+                    j += 1
+            else:
+                i += 1
+                try:
+                    while expected[i] == e:
+                        i += 1
+                finally:
+                    j += 1
+                    while actual[j] == a:
+                        j += 1
+        except IndexError:
+            missing.extend(expected[i:])
+            unexpected.extend(actual[j:])
+            break
+    return missing, unexpected
+
+def unorderable_list_difference(expected, actual, ignore_duplicate=False):
+    """Same behavior as sorted_list_difference but
+    for lists of unorderable items (like dicts).
+
+    As it does a linear search per item (remove) it
+    has O(n*n) performance.
+    """
+    missing = []
+    unexpected = []
+    while expected:
+        item = expected.pop()
+        try:
+            actual.remove(item)
+        except ValueError:
+            missing.append(item)
+        if ignore_duplicate:
+            for lst in expected, actual:
+                try:
+                    while True:
+                        lst.remove(item)
+                except ValueError:
+                    pass
+    if ignore_duplicate:
+        while actual:
+            item = actual.pop()
+            unexpected.append(item)
+            try:
+                while True:
+                    actual.remove(item)
+            except ValueError:
+                pass
+        return missing, unexpected
+
+    # anything left in actual is unexpected
+    return missing, actual

Reply via email to