|
22 | 22 | import textwrap
|
23 | 23 | import unittest
|
24 | 24 | from test import support
|
25 |
| -from test.support import os_helper, without_optimizer |
| 25 | +from test.support import import_helper |
| 26 | +from test.support import os_helper |
26 | 27 | from test.libregrtest import cmdline
|
27 | 28 | from test.libregrtest import main
|
28 | 29 | from test.libregrtest import setup
|
@@ -1178,7 +1179,7 @@ def test_run(self):
|
1178 | 1179 | stats=TestStats(4, 1),
|
1179 | 1180 | forever=True)
|
1180 | 1181 |
|
1181 |
| - @without_optimizer |
| 1182 | + @support.without_optimizer |
1182 | 1183 | def check_leak(self, code, what, *, run_workers=False):
|
1183 | 1184 | test = self.create_test('huntrleaks', code=code)
|
1184 | 1185 |
|
@@ -1746,10 +1747,9 @@ def test_other_bug(self):
|
1746 | 1747 |
|
1747 | 1748 | @support.cpython_only
|
1748 | 1749 | def test_uncollectable(self):
|
1749 |
| - try: |
1750 |
| - import _testcapi |
1751 |
| - except ImportError: |
1752 |
| - raise unittest.SkipTest("requires _testcapi") |
| 1750 | + # Skip test if _testcapi is missing |
| 1751 | + import_helper.import_module('_testcapi') |
| 1752 | + |
1753 | 1753 | code = textwrap.dedent(r"""
|
1754 | 1754 | import _testcapi
|
1755 | 1755 | import gc
|
@@ -2132,10 +2132,10 @@ def test_unload_tests(self):
|
2132 | 2132 |
|
2133 | 2133 | def check_add_python_opts(self, option):
|
2134 | 2134 | # --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
|
2135 |
| - try: |
2136 |
| - import _testinternalcapi |
2137 |
| - except ImportError: |
2138 |
| - raise unittest.SkipTest("requires _testinternalcapi") |
| 2135 | + |
| 2136 | + # Skip test if _testinternalcapi is missing |
| 2137 | + import_helper.import_module('_testinternalcapi') |
| 2138 | + |
2139 | 2139 | code = textwrap.dedent(r"""
|
2140 | 2140 | import sys
|
2141 | 2141 | import unittest
|
@@ -2198,10 +2198,8 @@ def test_add_python_opts(self):
|
2198 | 2198 | @unittest.skipIf(support.is_android,
|
2199 | 2199 | 'raising SIGSEGV on Android is unreliable')
|
2200 | 2200 | def test_worker_output_on_failure(self):
|
2201 |
| - try: |
2202 |
| - from faulthandler import _sigsegv |
2203 |
| - except ImportError: |
2204 |
| - self.skipTest("need faulthandler._sigsegv") |
| 2201 | + # Skip test if faulthandler is missing |
| 2202 | + import_helper.import_module('faulthandler') |
2205 | 2203 |
|
2206 | 2204 | code = textwrap.dedent(r"""
|
2207 | 2205 | import faulthandler
|
|
0 commit comments