Skip to content

Commit 7325883

Browse files
author
Johnny Chen
committed
o Added unittest2 which has added the new features in unittest for Python 2.7
backported to Python 2.3+. Some of the features desired include better verbose reporting in unittest2.TextTestRunner and decorator support for skipping tests and expected failures. http://pypi.python.org/pypi/unittest2 o Modified the existing .py tests to use unittest2 and decorated TestSTL.test_step_into_stl(), which is known to always fail currently, with @unittest2.expectedFailure. llvm-svn: 110397
1 parent 755aceb commit 7325883

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+8185
-32
lines changed

lldb/test/array_types/TestArrayTypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test breakpoint by file/line number; and list variables with array types."""
22

33
import os, time
4-
import unittest
4+
import unittest2
55
import lldb
66
import lldbtest
77

@@ -74,4 +74,4 @@ def test_array_types(self):
7474
import atexit
7575
lldb.SBDebugger.Initialize()
7676
atexit.register(lambda: lldb.SBDebugger.Terminate())
77-
unittest.main()
77+
unittest2.main()

lldb/test/class_types/TestClassTypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test breakpoint on a class constructor; and variable list the this object."""
22

33
import os, time
4-
import unittest
4+
import unittest2
55
import lldb
66
import lldbtest
77

@@ -51,4 +51,4 @@ def test_class_types(self):
5151
import atexit
5252
lldb.SBDebugger.Initialize()
5353
atexit.register(lambda: lldb.SBDebugger.Terminate())
54-
unittest.main()
54+
unittest2.main()

lldb/test/command_source/TestCommandSource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
import os, time
8-
import unittest
8+
import unittest2
99
import lldb
1010
import lldbtest
1111

@@ -33,4 +33,4 @@ def test_command_source(self):
3333
import atexit
3434
lldb.SBDebugger.Initialize()
3535
atexit.register(lambda: lldb.SBDebugger.Terminate())
36-
unittest.main()
36+
unittest2.main()

lldb/test/dead-strip/TestDeadStrip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import os, time
6-
import unittest
6+
import unittest2
77
import lldb
88
import lldbtest
99

@@ -82,4 +82,4 @@ def test_dead_strip(self):
8282
import atexit
8383
lldb.SBDebugger.Initialize()
8484
atexit.register(lambda: lldb.SBDebugger.Terminate())
85-
unittest.main()
85+
unittest2.main()

lldb/test/dotest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
import os
1818
import sys
1919
import time
20-
import unittest
20+
import unittest2
2121

2222
#
2323
# Global variables:
2424
#
2525

2626
# The test suite.
27-
suite = unittest.TestSuite()
27+
suite = unittest2.TestSuite()
2828

2929
# Default verbosity is 0.
3030
verbose = 0
@@ -122,7 +122,7 @@ def visit(prefix, dir, names):
122122
if not sys.path.count(dir):
123123
sys.path.append(dir)
124124
base = os.path.splitext(name)[0]
125-
suite.addTests(unittest.defaultTestLoader.loadTestsFromName(base))
125+
suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
126126

127127

128128
#
@@ -155,7 +155,7 @@ def visit(prefix, dir, names):
155155
if not res.Succeeded():
156156
raise Exception('log enable failed (check your LLDB_LOG env variable...')
157157

158-
unittest.TextTestRunner(verbosity=verbose).run(suite)
158+
unittest2.TextTestRunner(verbosity=verbose).run(suite)
159159

160160
# Add some delay before calling SBDebugger.Terminate().
161161
time.sleep(1)

lldb/test/function_types/TestFunctionTypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test variable with function ptr type and that break on the function works."""
22

33
import os, time
4-
import unittest
4+
import unittest2
55
import lldb
66
import lldbtest
77

@@ -67,4 +67,4 @@ def test_function_types(self):
6767
import atexit
6868
lldb.SBDebugger.Initialize()
6969
atexit.register(lambda: lldb.SBDebugger.Terminate())
70-
unittest.main()
70+
unittest2.main()

lldb/test/global_variables/TestGlobalVariables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Show global variables and check that they do indeed have global scopes."""
22

33
import os, time
4-
import unittest
4+
import unittest2
55
import lldb
66
import lldbtest
77

@@ -57,4 +57,4 @@ def test_global_variables(self):
5757
import atexit
5858
lldb.SBDebugger.Initialize()
5959
atexit.register(lambda: lldb.SBDebugger.Terminate())
60-
unittest.main()
60+
unittest2.main()

lldb/test/help/TestHelp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
import os, time
8-
import unittest
8+
import unittest2
99
import lldb
1010
import lldbtest
1111

@@ -39,4 +39,4 @@ def test_help_should_not_hang_emacsshell(self):
3939
import atexit
4040
lldb.SBDebugger.Initialize()
4141
atexit.register(lambda: lldb.SBDebugger.Terminate())
42-
unittest.main()
42+
unittest2.main()

lldb/test/lldbtest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
"""
2929

3030
import os
31-
import unittest
31+
import unittest2
3232
import lldb
3333
import traceback
3434

35-
class TestBase(unittest.TestCase):
35+
class TestBase(unittest2.TestCase):
3636
"""This LLDB abstract base class is meant to be subclassed."""
3737

3838
# The concrete subclass should override this attribute.

lldb/test/load_unload/TestLoadUnload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import os, time
6-
import unittest
6+
import unittest2
77
import lldb
88
import lldbtest
99

@@ -70,4 +70,4 @@ def test_load_unload(self):
7070
import atexit
7171
lldb.SBDebugger.Initialize()
7272
atexit.register(lambda: lldb.SBDebugger.Terminate())
73-
unittest.main()
73+
unittest2.main()

lldb/test/order/TestOrderFile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import os, time
66
import re
7-
import unittest
7+
import unittest2
88
import lldb
99
import lldbtest
1010

@@ -37,4 +37,4 @@ def test_order_file(self):
3737
import atexit
3838
lldb.SBDebugger.Initialize()
3939
atexit.register(lambda: lldb.SBDebugger.Terminate())
40-
unittest.main()
40+
unittest2.main()

lldb/test/set_values/TestSetValues.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test settings and readings of program variables."""
22

33
import os, time
4-
import unittest
4+
import unittest2
55
import lldb
66
import lldbtest
77

@@ -115,4 +115,4 @@ def test_set_values(self):
115115
import atexit
116116
lldb.SBDebugger.Initialize()
117117
atexit.register(lambda: lldb.SBDebugger.Terminate())
118-
unittest.main()
118+
unittest2.main()

lldb/test/stl/TestSTL.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"""
44

55
import os, time
6-
import unittest
6+
import unittest2
77
import lldb
88
import lldbtest
99

1010
class TestSTL(lldbtest.TestBase):
1111

1212
mydir = "stl"
1313

14+
@unittest2.expectedFailure
1415
def test_step_into_stl(self):
1516
"""Test that we can successfully step into an STL function."""
1617
res = self.res
@@ -75,4 +76,4 @@ def test_step_into_stl(self):
7576
import atexit
7677
lldb.SBDebugger.Initialize()
7778
atexit.register(lambda: lldb.SBDebugger.Terminate())
78-
unittest.main()
79+
unittest2.main()

lldb/test/struct_types/TestStructTypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
import os, time
8-
import unittest
8+
import unittest2
99
import lldb
1010
import lldbtest
1111

@@ -52,4 +52,4 @@ def test_struct_types(self):
5252
import atexit
5353
lldb.SBDebugger.Initialize()
5454
atexit.register(lambda: lldb.SBDebugger.Terminate())
55-
unittest.main()
55+
unittest2.main()

lldb/test/unittest2/__init__.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
__all__ = ['TestResult', 'TestCase', 'TestSuite',
30+
'TextTestRunner', 'TestLoader', 'FunctionTestCase', 'main',
31+
'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless',
32+
'expectedFailure', 'TextTestResult', '__version__', 'collector']
33+
34+
__version__ = '0.5.1'
35+
36+
# Expose obsolete functions for backwards compatibility
37+
__all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])
38+
39+
40+
from unittest2.collector import collector
41+
from unittest2.result import TestResult
42+
from unittest2.case import (
43+
TestCase, FunctionTestCase, SkipTest, skip, skipIf,
44+
skipUnless, expectedFailure
45+
)
46+
from unittest2.suite import BaseTestSuite, TestSuite
47+
from unittest2.loader import (
48+
TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
49+
findTestCases
50+
)
51+
from unittest2.main import TestProgram, main, main_
52+
from unittest2.runner import TextTestRunner, TextTestResult
53+
54+
try:
55+
from unittest2.signals import (
56+
installHandler, registerResult, removeResult, removeHandler
57+
)
58+
except ImportError:
59+
# Compatibility with platforms that don't have the signal module
60+
pass
61+
else:
62+
__all__.extend(['installHandler', 'registerResult', 'removeResult',
63+
'removeHandler'])
64+
65+
# deprecated
66+
_TextTestResult = TextTestResult
67+
68+
__unittest = True

lldb/test/unittest2/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Main entry point"""
2+
3+
import sys
4+
if sys.argv[0].endswith("__main__.py"):
5+
sys.argv[0] = "unittest2"
6+
7+
__unittest = True
8+
9+
from unittest2.main import main_
10+
main_()

0 commit comments

Comments
 (0)