]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - third_party/Python/module/unittest2/unittest2/__init__.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / third_party / Python / module / unittest2 / unittest2 / __init__.py
1 """
2 unittest2
3
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.
6
7 To use unittest2 instead of unittest simply replace ``import unittest`` with
8 ``import unittest2``.
9
10
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.
16
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
20 DAMAGE.
21
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.
27 """
28
29 import sys
30
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)
34 else:
35     cmp_ = cmp
36
37 reversed_cmp_ = lambda x, y: -cmp_(x,y)
38
39 __all__ = ['TestResult', 'TestCase', 'TestSuite',
40            'TextTestRunner', 'TestLoader', 'FunctionTestCase', 'main',
41            'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless',
42            'expectedFailure', 'TextTestResult', '__version__', 'collector']
43
44 __version__ = '0.5.1'
45
46 # Expose obsolete functions for backwards compatibility
47 __all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])
48
49
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
55 )
56 from unittest2.suite import BaseTestSuite, TestSuite
57 from unittest2.loader import (
58     TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
59     findTestCases
60 )
61 from unittest2.main import TestProgram, main, main_
62 from unittest2.runner import TextTestRunner, TextTestResult
63
64 try:
65     from unittest2.signals import (
66         installHandler, registerResult, removeResult, removeHandler
67     )
68 except ImportError:
69     # Compatibility with platforms that don't have the signal module
70     pass
71 else:
72     __all__.extend(['installHandler', 'registerResult', 'removeResult', 
73                     'removeHandler'])
74
75 # deprecated
76 _TextTestResult = TextTestResult
77
78 __unittest = True