From 145bf269df3530176f6ebeab1324890ef7070bf8 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 26 Feb 2021 14:51:55 -0800 Subject: bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917) Co-authored-by: Guido van Rossum Co-authored-by: Talin Co-authored-by: Pablo Galindo --- Lib/test/test_dataclasses.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Lib/test/test_dataclasses.py') diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 8887eb6461b..0bfed41b369 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -3375,5 +3375,21 @@ class TestAbstract(unittest.TestCase): self.assertRaisesRegex(TypeError, msg, Date) +class TestMatchArgs(unittest.TestCase): + def test_match_args(self): + @dataclass + class C: + a: int + self.assertEqual(C(42).__match_args__, ('a',)) + + def test_explicit_match_args(self): + ma = [] + @dataclass + class C: + a: int + __match_args__ = ma + self.assertIs(C(42).__match_args__, ma) + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3