MCPcopy Index your code
hub / github.com/RustPython/RustPython / check_disallow_instantiation

Function check_disallow_instantiation

Lib/test/support/__init__.py:2386–2400  ·  view source on GitHub ↗

Check that given type cannot be instantiated using *args and **kwds. See bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag.

(testcase, tp, *args, **kwds)

Source from the content-addressed store, hash-verified

2384
2385
2386def check_disallow_instantiation(testcase, tp, *args, **kwds):
2387 """
2388 Check that given type cannot be instantiated using *args and **kwds.
2389
2390 See bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag.
2391 """
2392 mod = tp.__module__
2393 name = tp.__name__
2394 if mod != 'builtins':
2395 qualname = f"{mod}.{name}"
2396 else:
2397 qualname = f"{name}"
2398 msg = f"cannot create '{re.escape(qualname)}' instances"
2399 testcase.assertRaisesRegex(TypeError, msg, tp, *args, **kwds)
2400 testcase.assertRaisesRegex(TypeError, msg, tp.__new__, tp, *args, **kwds)
2401
2402def get_recursion_depth():
2403 """Get the recursion depth of the caller function.

Calls 2

escapeMethod · 0.80
assertRaisesRegexMethod · 0.80