8000 Add a test that asserts the correct behaviour · python/cpython@3932d48 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3932d48

Browse files
committed
Add a test that asserts the correct behaviour
1 parent fdab495 commit 3932d48

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_typing.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7577,6 +7577,21 @@ class NamedTupleClass(NamedTuple):
75777577
normal_exception.__notes__[0].replace("NormalClass", "NamedTupleClass")
75787578
)
75797579

7580+
def test_strange_errors_when_accessing_set_name_itself(self):
7581+
class Meta(type):
7582+
def __getattribute__(self, attr):
7583+
if attr == "__set_name__":
7584+
raise TypeError("NO")
7585+
return object.__getattribute__(self, attr)
7586+
7587+
class VeryAnnoying(metaclass=Meta): pass
7588+
7589+
annoying = VeryAnnoying()
7590+
7591+
with self.assertRaisesRegex(TypeError, "NO"):
7592+
class Foo(NamedTuple):
7593+
attr = annoying
7594+
75807595

75817596
class TypedDictTests(BaseTestCase):
75827597
def test_basics_functional_syntax(self):

0 commit comments

Comments
 (0)
0