diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-05-27 06:43:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 06:43:52 (GMT) |
commit | fbff5387c3e1f3904420fa5a27738c6c5881305b (patch) | |
tree | a4e01083dde3afdde7306e55f70c1493fdc07b0a /Lib/test/support | |
parent | 3e7ee02327db13e4337374597cdc4458ecb9e3ad (diff) | |
download | cpython-fbff5387c3e1f3904420fa5a27738c6c5881305b.zip cpython-fbff5387c3e1f3904420fa5a27738c6c5881305b.tar.gz cpython-fbff5387c3e1f3904420fa5a27738c6c5881305b.tar.bz2 |
bpo-43988: Use check disallow instantiation helper (GH-26392)
Diffstat (limited to 'Lib/test/support')
-rw-r--r-- | Lib/test/support/__init__.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 8c6e554..42ca614 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -1991,5 +1991,11 @@ def check_disallow_instantiation(testcase, tp, *args, **kwds): See bpo-43916. """ - msg = f"cannot create '{tp.__module__}\.{tp.__name__}' instances" + mod = tp.__module__ + name = tp.__name__ + if mod != 'builtins': + qualname = f"{mod}.{name}" + else: + qualname = f"{name}" + msg = f"cannot create '{re.escape(qualname)}' instances" testcase.assertRaisesRegex(TypeError, msg, tp, *args, **kwds) |