Skip to content

Commit fa34f52

Browse files
committed
Blanket unittest2 -> unittest replacement (excluding docs)
1 parent 6b33047 commit fa34f52

File tree

17 files changed

+61
-61
lines changed

17 files changed

+61
-61
lines changed

lldb/packages/Python/lldbsuite/test/configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313

1414
# Third-party modules
15-
import unittest2
15+
import unittest
1616

1717
# LLDB Modules
1818
import lldbsuite
1919

2020

2121
# The test suite.
22-
suite = unittest2.TestSuite()
22+
suite = unittest.TestSuite()
2323

2424
# The list of categories we said we care about
2525
categories_list = None

lldb/packages/Python/lldbsuite/test/decorators.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import subprocess
1212

1313
# Third-party modules
14-
import unittest2
14+
import unittest
1515

1616
# LLDB modules
1717
import lldb
@@ -115,11 +115,11 @@ def _compiler_supports(
115115

116116
def expectedFailureIf(condition, bugnumber=None):
117117
def expectedFailure_impl(func):
118-
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
118+
if isinstance(func, type) and issubclass(func, unittest.TestCase):
119119
raise Exception("Decorator can only be used to decorate a test method")
120120

121121
if condition:
122-
return unittest2.expectedFailure(func)
122+
return unittest.expectedFailure(func)
123123
return func
124124

125125
if callable(bugnumber):
@@ -130,14 +130,14 @@ def expectedFailure_impl(func):
130130

131131
def expectedFailureIfFn(expected_fn, bugnumber=None):
132132
def expectedFailure_impl(func):
133-
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
133+
if isinstance(func, type) and issubclass(func, unittest.TestCase):
134134
raise Exception("Decorator can only be used to decorate a test method")
135135

136136
@wraps(func)
137137
def wrapper(*args, **kwargs):
138138
xfail_reason = expected_fn(*args, **kwargs)
139139
if xfail_reason is not None:
140-
xfail_func = unittest2.expectedFailure(func)
140+
xfail_func = unittest.expectedFailure(func)
141141
xfail_func(*args, **kwargs)
142142
else:
143143
func(*args, **kwargs)
@@ -157,11 +157,11 @@ def wrapper(*args, **kwargs):
157157

158158
def skipTestIfFn(expected_fn, bugnumber=None):
159159
def skipTestIfFn_impl(func):
160-
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
160+
if isinstance(func, type) and issubclass(func, unittest.TestCase):
161161
reason = expected_fn()
162162
# The return value is the reason (or None if we don't skip), so
163163
# reason is used for both args.
164-
return unittest2.skipIf(condition=reason, reason=reason)(func)
164+
return unittest.skipIf(condition=reason, reason=reason)(func)
165165

166166
@wraps(func)
167167
def wrapper(*args, **kwargs):
@@ -191,7 +191,7 @@ def wrapper(*args, **kwargs):
191191

192192
def _xfailForDebugInfo(expected_fn, bugnumber=None):
193193
def expectedFailure_impl(func):
194-
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
194+
if isinstance(func, type) and issubclass(func, unittest.TestCase):
195195
raise Exception("Decorator can only be used to decorate a test method")
196196

197197
func.__xfail_for_debug_info_cat_fn__ = expected_fn
@@ -205,7 +205,7 @@ def expectedFailure_impl(func):
205205

206206
def _skipForDebugInfo(expected_fn, bugnumber=None):
207207
def skipImpl(func):
208-
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
208+
if isinstance(func, type) and issubclass(func, unittest.TestCase):
209209
raise Exception("Decorator can only be used to decorate a test method")
210210

211211
func.__skip_for_debug_info_cat_fn__ = expected_fn
@@ -434,7 +434,7 @@ def add_test_categories(cat):
434434
cat = test_categories.validate(cat, True)
435435

436436
def impl(func):
437-
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
437+
if isinstance(func, type) and issubclass(func, unittest.TestCase):
438438
raise Exception(
439439
"@add_test_categories can only be used to decorate a test method"
440440
)
@@ -465,7 +465,7 @@ def should_skip_benchmarks_test():
465465
def no_debug_info_test(func):
466466
"""Decorate the item as a test what don't use any debug info. If this annotation is specified
467467
then the test runner won't generate a separate test for each debug info format."""
468-
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
468+
if isinstance(func, type) and issubclass(func, unittest.TestCase):
469469
raise Exception(
470470
"@no_debug_info_test can only be used to decorate a test method"
471471
)
@@ -631,7 +631,7 @@ def is_out_of_tree_debugserver():
631631

632632
def skipIfRemote(func):
633633
"""Decorate the item to skip tests if testing remotely."""
634-
return unittest2.skipIf(lldb.remote_platform, "skip on remote platform")(func)
634+
return unittest.skipIf(lldb.remote_platform, "skip on remote platform")(func)
635635

636636

637637
def skipIfNoSBHeaders(func):
@@ -768,7 +768,7 @@ def skipUnlessDarwin(func):
768768

769769

770770
def skipUnlessTargetAndroid(func):
771-
return unittest2.skipUnless(
771+
return unittest.skipUnless(
772772
lldbplatformutil.target_is_android(), "requires target to be Android"
773773
)(func)
774774

@@ -809,7 +809,7 @@ def skipIfPlatform(oslist):
809809
"""Decorate the item to skip tests if running on one of the listed platforms."""
810810
# This decorator cannot be ported to `skipIf` yet because it is used on entire
811811
# classes, which `skipIf` explicitly forbids.
812-
return unittest2.skipIf(
812+
return unittest.skipIf(
813813
lldbplatformutil.getPlatform() in oslist, "skip on %s" % (", ".join(oslist))
814814
)
815815

@@ -818,7 +818,7 @@ def skipUnlessPlatform(oslist):
818818
"""Decorate the item to skip tests unless running on one of the listed platforms."""
819819
# This decorator cannot be ported to `skipIf` yet because it is used on entire
820820
# classes, which `skipIf` explicitly forbids.
821-
return unittest2.skipUnless(
821+
return unittest.skipUnless(
822822
lldbplatformutil.getPlatform() in oslist,
823823
"requires one of %s" % (", ".join(oslist)),
824824
)
@@ -1078,7 +1078,7 @@ def _get_bool_config(key, fail_value=True):
10781078

10791079
def _get_bool_config_skip_if_decorator(key):
10801080
have = _get_bool_config(key)
1081-
return unittest2.skipIf(not have, "requires " + key)
1081+
return unittest.skipIf(not have, "requires " + key)
10821082

10831083

10841084
def skipIfCursesSupportMissing(func):
@@ -1110,7 +1110,7 @@ def skipIfLLVMTargetMissing(target):
11101110
found = True
11111111
break
11121112

1113-
return unittest2.skipIf(not found, "requires " + target)
1113+
return unittest.skipIf(not found, "requires " + target)
11141114

11151115

11161116
# Call sysctl on darwin to see if a specified hardware feature is available on this machine.

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import tempfile
3434

3535
# Third-party modules
36-
import unittest2
36+
import unittest
3737

3838
# LLDB Modules
3939
import lldbsuite
@@ -658,7 +658,7 @@ def iter_filters():
658658
for filterspec in iter_filters():
659659
filtered = True
660660
print("adding filter spec %s to module %s" % (filterspec, repr(module)))
661-
tests = unittest2.defaultTestLoader.loadTestsFromName(filterspec, module)
661+
tests = unittest.defaultTestLoader.loadTestsFromName(filterspec, module)
662662
configuration.suite.addTests(tests)
663663

664664
# Forgo this module if the (base, filterspec) combo is invalid
@@ -670,7 +670,7 @@ def iter_filters():
670670
# Also the fail-over case when the filterspec branch
671671
# (base, filterspec) combo doesn't make sense.
672672
configuration.suite.addTests(
673-
unittest2.defaultTestLoader.loadTestsFromName(base)
673+
unittest.defaultTestLoader.loadTestsFromName(base)
674674
)
675675

676676

@@ -1032,7 +1032,7 @@ def run_suite():
10321032
#
10331033

10341034
# Install the control-c handler.
1035-
unittest2.signals.installHandler()
1035+
unittest.signals.installHandler()
10361036

10371037
#
10381038
# Invoke the default TextTestRunner to run the test suite
@@ -1066,7 +1066,7 @@ def run_suite():
10661066

10671067
# Invoke the test runner.
10681068
if configuration.count == 1:
1069-
result = unittest2.TextTestRunner(
1069+
result = unittest.TextTestRunner(
10701070
stream=sys.stderr,
10711071
verbosity=configuration.verbose,
10721072
resultclass=test_result.LLDBTestResult,
@@ -1077,7 +1077,7 @@ def run_suite():
10771077
# not enforced.
10781078
test_result.LLDBTestResult.__ignore_singleton__ = True
10791079
for i in range(configuration.count):
1080-
result = unittest2.TextTestRunner(
1080+
result = unittest.TextTestRunner(
10811081
stream=sys.stderr,
10821082
verbosity=configuration.verbose,
10831083
resultclass=test_result.LLDBTestResult,

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import traceback
4545

4646
# Third-party modules
47-
import unittest2
47+
import unittest
4848

4949
# LLDB modules
5050
import lldb
@@ -517,7 +517,7 @@ def builder_module():
517517
return lldbplatformutil.builder_module()
518518

519519

520-
class Base(unittest2.TestCase):
520+
class Base(unittest.TestCase):
521521
"""
522522
Abstract base for performing lldb (see TestBase) or other generic tests (see
523523
BenchBase for one example). lldbtest.Base works with the test driver to
@@ -1704,13 +1704,13 @@ def test_method(self, attrvalue=attrvalue):
17041704

17051705
xfail_reason = xfail_for_debug_info_cat_fn(cat)
17061706
if xfail_reason:
1707-
test_method = unittest2.expectedFailure(xfail_reason)(
1707+
test_method = unittest.expectedFailure(xfail_reason)(
17081708
test_method
17091709
)
17101710

17111711
skip_reason = skip_for_debug_info_cat_fn(cat)
17121712
if skip_reason:
1713-
test_method = unittest2.skip(skip_reason)(test_method)
1713+
test_method = unittest.skip(skip_reason)(test_method)
17141714

17151715
newattrs[method_name] = test_method
17161716

lldb/packages/Python/lldbsuite/test/test_result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
import traceback
1313

1414
# Third-party modules
15-
import unittest2
15+
import unittest
1616

1717
# LLDB Modules
1818
from . import configuration
1919
from lldbsuite.test_event import build_exception
2020

2121

22-
class LLDBTestResult(unittest2.TextTestResult):
22+
class LLDBTestResult(unittest.TextTestResult):
2323
"""
2424
Enforce a singleton pattern to allow introspection of test progress.
2525

lldb/test/API/commands/expression/test/TestExprs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"""
1313

1414

15-
import unittest2
15+
import unittest
1616
import lldb
1717
from lldbsuite.test.decorators import *
1818
from lldbsuite.test.lldbtest import *
@@ -46,7 +46,7 @@ def build_and_run(self):
4646

4747
# llvm.org/pr17135 <rdar://problem/14874559>
4848
# APFloat::toString does not identify the correct (i.e. least) precision.
49-
@unittest2.expectedFailure
49+
@unittest.expectedFailure
5050
def test_floating_point_expr_commands(self):
5151
self.build_and_run()
5252

lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/TestThreadPlanUserBreakpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010

11-
import unittest2
11+
import unittest
1212
import lldb
1313
from lldbsuite.test.decorators import *
1414
from lldbsuite.test.lldbtest import *

lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test for the JITLoaderGDB interface"""
22

33

4-
import unittest2
4+
import unittest
55
import os
66
import lldb
77
from lldbsuite.test import lldbutil
@@ -14,7 +14,7 @@ class JITLoaderGDBTestCase(TestBase):
1414
lambda: "Skipped because the test crashes the test runner",
1515
bugnumber="llvm.org/pr24702",
1616
)
17-
@unittest2.expectedFailure # llvm.org/pr24702
17+
@unittest.expectedFailure # llvm.org/pr24702
1818
def test_bogus_values(self):
1919
"""Test that we handle inferior misusing the GDB JIT interface"""
2020
self.build()

lldb/test/API/functionalities/thread/state/TestThreadStates.py

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

55

6-
import unittest2
6+
import unittest
77
import lldb
88
from lldbsuite.test.decorators import *
99
from lldbsuite.test.lldbtest import *
@@ -41,14 +41,14 @@ def test_state_after_continue(self):
4141
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660")
4242
@expectedFailureNetBSD
4343
# thread states not properly maintained
44-
@unittest2.expectedFailure # llvm.org/pr16712
44+
@unittest.expectedFailure # llvm.org/pr16712
4545
def test_state_after_expression(self):
4646
"""Test thread state after expression."""
4747
self.build()
4848
self.thread_state_after_expression_test()
4949

5050
# thread states not properly maintained
51-
@unittest2.expectedFailure # llvm.org/pr15824 and <rdar://problem/28557237>
51+
@unittest.expectedFailure # llvm.org/pr15824 and <rdar://problem/28557237>
5252
@expectedFailureAll(
5353
oslist=["windows"],
5454
bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly",

lldb/test/API/functionalities/tty/TestTerminal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Test lldb command aliases.
33
"""
44

5-
import unittest2
5+
import unittest
66
import os
77
import lldb
88
from lldbsuite.test.decorators import *
@@ -17,13 +17,13 @@ class LaunchInTerminalTestCase(TestBase):
1717
@skipUnlessDarwin
1818
# If the test is being run under sudo, the spawned terminal won't retain that elevated
1919
# privilege so it can't open the socket to talk back to the test case
20-
@unittest2.skipIf(
20+
@unittest.skipIf(
2121
hasattr(os, "geteuid") and os.geteuid() == 0, "test cannot be run as root"
2222
)
2323
# Do we need to disable this test if the testsuite is being run on a remote system?
2424
# This env var is only defined when the shell is running in a local mac
2525
# terminal window
26-
@unittest2.skipUnless(
26+
@unittest.skipUnless(
2727
"TERM_PROGRAM" in os.environ, "test must be run on local system"
2828
)
2929
@no_debug_info_test

lldb/test/API/lang/c/shared_lib/TestSharedLib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test that types defined in shared libraries work correctly."""
22

33

4-
import unittest2
4+
import unittest
55
import lldb
66
from lldbsuite.test.decorators import *
77
from lldbsuite.test.lldbtest import *
@@ -35,7 +35,7 @@ def test_expr_no_preload(self):
3535
"""Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled"""
3636
self.common_test_expr(False)
3737

38-
@unittest2.expectedFailure # llvm.org/PR36712
38+
@unittest.expectedFailure # llvm.org/PR36712
3939
def test_frame_variable(self):
4040
"""Test that types work when defined in a shared library and forward-declared in the main executable"""
4141
self.build()

lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test that types defined in shared libraries with stripped symbols work correctly."""
22

33

4-
import unittest2
4+
import unittest
55
import lldb
66
from lldbsuite.test.decorators import *
77
from lldbsuite.test.lldbtest import *
@@ -28,7 +28,7 @@ def test_expr(self):
2828
)
2929

3030
@expectedFailureAll(oslist=["windows"])
31-
@unittest2.expectedFailure # llvm.org/PR36712
31+
@unittest.expectedFailure # llvm.org/PR36712
3232
def test_frame_variable(self):
3333
"""Test that types work when defined in a shared library and forward-declared in the main executable"""
3434
self.build()

0 commit comments

Comments
 (0)