Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Add requires_singlephase_init.
  • Loading branch information
ericsnowcurrently committed Mar 9, 2023
commit 63f3015904eb6829f340cf77963101f82555351b
12 changes: 10 additions & 2 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def requires_subinterpreters(meth):
'subinterpreters required')(meth)


def requires_singlephase_init(meth):
"""Decorator to skip if single-phase init modules are not supported."""
meth = cpython_only(meth)
return unittest.skipIf(_testsinglephase is None,
'test requires _testsinglephase module')(meth)


class ModuleSnapshot(types.SimpleNamespace):
"""A representation of a module for testing.

Expand Down Expand Up @@ -1720,7 +1727,7 @@ def test_frozen_compat(self):
with self.subTest(f'{module}: strict, shared'):
self.check_compatible_shared(module, strict=True)

@unittest.skipIf(_testsinglephase is None, "test requires _testsinglephase module")
@requires_singlephase_init
def test_single_init_extension_compat(self):
module = '_testsinglephase'
with self.subTest(f'{module}: not strict'):
Expand Down Expand Up @@ -1751,7 +1758,7 @@ def test_python_compat(self):
with self.subTest(f'{module}: strict, isolated'):
self.check_compatible_isolated(module, strict=True)

@unittest.skipIf(_testsinglephase is None, "test requires _testsinglephase module")
@requires_singlephase_init
def test_singlephase_check_with_setting_and_override(self):
module = '_testsinglephase'

Expand Down Expand Up @@ -1824,6 +1831,7 @@ def parse(cls, text):
return self


@requires_singlephase_init
class SinglephaseInitTests(unittest.TestCase):

NAME = '_testsinglephase'
Expand Down