Skip to content

Commit 81c7605

Browse files
Improve tests.
1 parent 154a82a commit 81c7605

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Lib/test/test_capi/test_sys.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ def test_sys_getattr(self):
2828
with support.swap_attr(sys, '\U0001f40d', 42):
2929
self.assertEqual(sys_getattr('\U0001f40d'), 42)
3030

31-
with self.assertRaisesRegex(RuntimeError, r'lost sys\.nonexisting'):
32-
sys_getattr('nonexisting')
31+
with self.assertRaisesRegex(RuntimeError, r'lost sys\.nonexistent'):
32+
sys_getattr('nonexistent')
33+
with self.assertRaisesRegex(RuntimeError, r'lost sys\.\U0001f40d'):
34+
sys_getattr('\U0001f40d')
3335
self.assertRaises(TypeError, sys_getattr, 1)
3436
self.assertRaises(TypeError, sys_getattr, [])
3537
# CRASHES sys_getattr(NULL)
@@ -43,8 +45,10 @@ def test_sys_getattrstring(self):
4345
with support.swap_attr(sys, '\U0001f40d', 42):
4446
self.assertEqual(getattrstring('\U0001f40d'.encode()), 42)
4547

46-
with self.assertRaisesRegex(RuntimeError, r'lost sys\.nonexisting'):
47-
getattrstring(b'nonexisting')
48+
with self.assertRaisesRegex(RuntimeError, r'lost sys\.nonexistent'):
49+
getattrstring(b'nonexistent')
50+
with self.assertRaisesRegex(RuntimeError, r'lost sys\.\U0001f40d'):
51+
getattrstring('\U0001f40d'.encode())
4852
self.assertRaises(UnicodeDecodeError, getattrstring, b'\xff')
4953
# CRASHES getattrstring(NULL)
5054

@@ -57,7 +61,8 @@ def test_sys_getoptionalattr(self):
5761
with support.swap_attr(sys, '\U0001f40d', 42):
5862
self.assertEqual(getoptionalattr('\U0001f40d'), 42)
5963

60-
self.assertIs(getoptionalattr('nonexisting'), AttributeError)
64+
self.assertIs(getoptionalattr('nonexistent'), AttributeError)
65+
self.assertIs(getoptionalattr('\U0001f40d'), AttributeError)
6166
self.assertRaises(TypeError, getoptionalattr, 1)
6267
self.assertRaises(TypeError, getoptionalattr, [])
6368
# CRASHES getoptionalattr(NULL)
@@ -71,7 +76,8 @@ def test_sys_getoptionalattrstring(self):
7176
with support.swap_attr(sys, '\U0001f40d', 42):
7277
self.assertEqual(getoptionalattrstring('\U0001f40d'.encode()), 42)
7378

74-
self.assertIs(getoptionalattrstring(b'nonexisting'), AttributeError)
79+
self.assertIs(getoptionalattrstring(b'nonexistent'), AttributeError)
80+
self.assertIs(getoptionalattrstring('\U0001f40d'.encode()), AttributeError)
7581
self.assertRaises(UnicodeDecodeError, getoptionalattrstring, b'\xff')
7682
# CRASHES getoptionalattrstring(NULL)
7783

@@ -85,7 +91,7 @@ def test_sys_getobject(self):
8591
with support.swap_attr(sys, '\U0001f40d', 42):
8692
self.assertEqual(getobject('\U0001f40d'.encode()), 42)
8793

88-
self.assertIs(getobject(b'nonexisting'), AttributeError)
94+
self.assertIs(getobject(b'nonexistent'), AttributeError)
8995
with support.catch_unraisable_exception() as cm:
9096
self.assertIs(getobject(b'\xff'), AttributeError)
9197
self.assertEqual(cm.unraisable.exc_type, UnicodeDecodeError)

0 commit comments

Comments
 (0)