Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-120417: Use import_helper() in test_regrtest #120680

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import textwrap
import unittest
from test import support
from test.support import os_helper, without_optimizer
from test.support import import_helper
from test.support import os_helper
from test.libregrtest import cmdline
from test.libregrtest import main
from test.libregrtest import setup
Expand Down Expand Up @@ -1178,7 +1179,7 @@ def test_run(self):
stats=TestStats(4, 1),
forever=True)

@without_optimizer
@support.without_optimizer
def check_leak(self, code, what, *, run_workers=False):
test = self.create_test('huntrleaks', code=code)

Expand Down Expand Up @@ -1746,10 +1747,9 @@ def test_other_bug(self):

@support.cpython_only
def test_uncollectable(self):
try:
import _testcapi
except ImportError:
raise unittest.SkipTest("requires _testcapi")
# Skip test if _testcapi is missing
import_helper.import_module('_testcapi')

code = textwrap.dedent(r"""
import _testcapi
import gc
Expand Down Expand Up @@ -2132,10 +2132,10 @@ def test_unload_tests(self):

def check_add_python_opts(self, option):
# --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
try:
import _testinternalcapi
except ImportError:
raise unittest.SkipTest("requires _testinternalcapi")

# Skip test if _testinternalcapi is missing
import_helper.import_module('_testinternalcapi')

code = textwrap.dedent(r"""
import sys
import unittest
Expand Down Expand Up @@ -2198,10 +2198,8 @@ def test_add_python_opts(self):
@unittest.skipIf(support.is_android,
'raising SIGSEGV on Android is unreliable')
def test_worker_output_on_failure(self):
try:
from faulthandler import _sigsegv
except ImportError:
self.skipTest("need faulthandler._sigsegv")
# Skip test if faulthandler is missing
import_helper.import_module('faulthandler')

code = textwrap.dedent(r"""
import faulthandler
Expand Down
Loading