4 unittest2 is a backport of the new features added to the unittest testing
5 framework in Python 2.7. It is tested to run on Python 2.4 - 2.6.
7 To use unittest2 instead of unittest simply replace ``import unittest`` with
11 Copyright (c) 1999-2003 Steve Purcell
12 Copyright (c) 2003-2010 Python Software Foundation
13 This module is free software, and you may redistribute it and/or modify
14 it under the same terms as Python itself, so long as this copyright message
15 and disclaimer are retained in their original form.
17 IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
18 SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
19 THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
22 THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
25 AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
26 SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31 if sys.version_info[0] >= 3:
32 # Python 3 doesn't have the builtin `cmp` function anymore
33 cmp_ = lambda x, y: (x > y) - (x < y)
37 reversed_cmp_ = lambda x, y: -cmp_(x,y)
39 __all__ = ['TestResult', 'TestCase', 'TestSuite',
40 'TextTestRunner', 'TestLoader', 'FunctionTestCase', 'main',
41 'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless',
42 'expectedFailure', 'TextTestResult', '__version__', 'collector']
46 # Expose obsolete functions for backwards compatibility
47 __all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])
50 from unittest2.collector import collector
51 from unittest2.result import TestResult
52 from unittest2.case import (
53 TestCase, FunctionTestCase, SkipTest, skip, skipIf,
54 skipUnless, expectedFailure
56 from unittest2.suite import BaseTestSuite, TestSuite
57 from unittest2.loader import (
58 TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
61 from unittest2.main import TestProgram, main, main_
62 from unittest2.runner import TextTestRunner, TextTestResult
65 from unittest2.signals import (
66 installHandler, registerResult, removeResult, removeHandler
69 # Compatibility with platforms that don't have the signal module
72 __all__.extend(['installHandler', 'registerResult', 'removeResult',
76 _TextTestResult = TextTestResult