mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)
Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
cc02b4f2e8
commit
145bf269df
43 changed files with 10867 additions and 2607 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue