summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dataclasses.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rw-r--r--Lib/test/test_dataclasses.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index 7c1d9c5..8887eb6 100644
--- a/Lib/test/test_dataclasses.py
+++ b/Lib/test/test_dataclasses.py
@@ -1936,6 +1936,30 @@ class TestCase(unittest.TestCase):
self.assertEqual(new_sample.x, another_new_sample.x)
self.assertEqual(sample.y, another_new_sample.y)
+ def test_dataclasses_qualnames(self):
+ @dataclass(order=True, unsafe_hash=True, frozen=True)
+ class A:
+ x: int
+ y: int
+
+ self.assertEqual(A.__init__.__name__, "__init__")
+ for function in (
+ '__eq__',
+ '__lt__',
+ '__le__',
+ '__gt__',
+ '__ge__',
+ '__hash__',
+ '__init__',
+ '__repr__',
+ '__setattr__',
+ '__delattr__',
+ ):
+ self.assertEqual(getattr(A, function).__qualname__, f"TestCase.test_dataclasses_qualnames.<locals>.A.{function}")
+
+ with self.assertRaisesRegex(TypeError, r"A\.__init__\(\) missing"):
+ A()
+
class TestFieldNoAnnotation(unittest.TestCase):
def test_field_without_annotation(self):