mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-43988: Add test.support.check_disallow_instantiation() (GH-25757)
This commit is contained in:
parent
46db39d7bd
commit
4f725261c6
2 changed files with 14 additions and 3 deletions
|
@ -40,6 +40,7 @@ __all__ = [
|
|||
"requires_IEEE_754", "requires_zlib",
|
||||
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
|
||||
"check__all__", "skip_if_buggy_ucrt_strfptime",
|
||||
"check_disallow_instantiation",
|
||||
# sys
|
||||
"is_jython", "is_android", "check_impl_detail", "unix_shell",
|
||||
"setswitchinterval",
|
||||
|
@ -1982,3 +1983,13 @@ def skip_if_broken_multiprocessing_synchronize():
|
|||
synchronize.Lock(ctx=None)
|
||||
except OSError as exc:
|
||||
raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")
|
||||
|
||||
|
||||
def check_disallow_instantiation(testcase, tp, *args, **kwds):
|
||||
"""
|
||||
Helper for testing types with the Py_TPFLAGS_DISALLOW_INSTANTIATION flag.
|
||||
|
||||
See bpo-43916.
|
||||
"""
|
||||
msg = f"cannot create '{tp.__module__}\.{tp.__name__}' instances"
|
||||
testcase.assertRaisesRegex(TypeError, msg, tp, *args, **kwds)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue