diff options
author | Brandt Bucher <brandt@python.org> | 2021-04-06 02:17:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 02:17:08 (GMT) |
commit | f84d5a113680c5a6aaaf9130aed7a34d611748ff (patch) | |
tree | cde22e0e7ee970e49e10b6a5b137fe4f90d444f8 /Lib/test/test_patma.py | |
parent | 3d4af4a876e679431c6a3751667ded63cc6f66c1 (diff) | |
download | cpython-f84d5a113680c5a6aaaf9130aed7a34d611748ff.zip cpython-f84d5a113680c5a6aaaf9130aed7a34d611748ff.tar.gz cpython-f84d5a113680c5a6aaaf9130aed7a34d611748ff.tar.bz2 |
bpo-42128: __match_args__ can't be a list anymore (GH-25203)
Diffstat (limited to 'Lib/test/test_patma.py')
-rw-r--r-- | Lib/test/test_patma.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 286b190..40580be 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -17,7 +17,7 @@ def no_perf(f): class MyClass: x: int y: str - __match_args__ = ["x", "y"] + __match_args__ = ("x", "y") @dataclasses.dataclass @@ -2018,7 +2018,7 @@ class TestPatma(unittest.TestCase): def test_patma_200(self): class Class: - __match_args__ = ["a", "b"] + __match_args__ = ("a", "b") c = Class() c.a = 0 c.b = 1 @@ -2046,7 +2046,7 @@ class TestPatma(unittest.TestCase): class Parent: __match_args__ = "a", "b" class Child(Parent): - __match_args__ = ["c", "d"] + __match_args__ = ("c", "d") c = Child() c.a = 0 c.b = 1 @@ -2500,7 +2500,7 @@ class TestPatma(unittest.TestCase): @no_perf def test_patma_248(self): class Class: - __match_args__ = [None] + __match_args__ = (None,) x = Class() y = z = None with self.assertRaises(TypeError): @@ -2513,7 +2513,7 @@ class TestPatma(unittest.TestCase): @no_perf def test_patma_249(self): class Class: - __match_args__ = [] + __match_args__ = () x = Class() y = z = None with self.assertRaises(TypeError): @@ -2560,7 +2560,7 @@ class TestPatma(unittest.TestCase): @no_perf def test_patma_253(self): class Class: - __match_args__ = ["a", "a"] + __match_args__ = ("a", "a") a = None x = Class() w = y = z = None @@ -2575,7 +2575,7 @@ class TestPatma(unittest.TestCase): @no_perf def test_patma_254(self): class Class: - __match_args__ = ["a"] + __match_args__ = ("a",) a = None x = Class() w = y = z = None @@ -2841,6 +2841,22 @@ class TestPatma(unittest.TestCase): self.assertEqual(x, range(10)) self.assertIs(y, None) + @no_perf + def test_patma_282(self): + class Class: + __match_args__ = ["spam", "eggs"] + spam = 0 + eggs = 1 + x = Class() + w = y = z = None + with self.assertRaises(TypeError): + match x: + case Class(y, z): + w = 0 + self.assertIs(w, None) + self.assertIs(y, None) + self.assertIs(z, None) + class PerfPatma(TestPatma): |