diff options
author | Mark Shannon <mark@hotpy.org> | 2021-05-03 00:38:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-03 00:38:22 +0100 |
commit | 33ec88ac81f23668293d101b83367b086c795e5e (patch) | |
tree | ba5203f9375440ef1f63ceffe55f423d3b28195b /Lib/test/test_patma.py | |
parent | 9387fac100db359cbb6ec2a76f8a5eba8f9d7b65 (diff) | |
download | cpython-git-33ec88ac81f23668293d101b83367b086c795e5e.tar.gz |
bpo-43977: Make sure that tp_flags for pattern matching are inherited correctly. (GH-25813)
Diffstat (limited to 'Lib/test/test_patma.py')
-rw-r--r-- | Lib/test/test_patma.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 8a273be725..084d0879f1 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2979,6 +2979,47 @@ class TestPatma(unittest.TestCase): self.assertEqual(f((False, range(10, 20), True)), alts[4]) +class TestInheritance(unittest.TestCase): + + def test_multiple_inheritance(self): + class C: + pass + class S1(collections.UserList, collections.abc.Mapping): + pass + class S2(C, collections.UserList, collections.abc.Mapping): + pass + class S3(list, C, collections.abc.Mapping): + pass + class S4(collections.UserList, dict, C): + pass + class M1(collections.UserDict, collections.abc.Sequence): + pass + class M2(C, collections.UserDict, collections.abc.Sequence): + pass + class M3(collections.UserDict, C, list): + pass + class M4(dict, collections.abc.Sequence, C): + pass + def f(x): + match x: + case []: + return "seq" + case {}: + return "map" + def g(x): + match x: + case {}: + return "map" + case []: + return "seq" + for Seq in (S1, S2, S3, S4): + self.assertEqual(f(Seq()), "seq") + self.assertEqual(g(Seq()), "seq") + for Map in (M1, M2, M3, M4): + self.assertEqual(f(Map()), "map") + self.assertEqual(g(Map()), "map") + + class PerfPatma(TestPatma): def assertEqual(*_, **__): |