summaryrefslogtreecommitdiff
path: root/tests/run/test_patma.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/test_patma.py')
-rw-r--r--tests/run/test_patma.py293
1 files changed, 166 insertions, 127 deletions
diff --git a/tests/run/test_patma.py b/tests/run/test_patma.py
index 33545cd08..aae22c18c 100644
--- a/tests/run/test_patma.py
+++ b/tests/run/test_patma.py
@@ -1,43 +1,21 @@
-### COPIED FROM CPython 3.9
+### COPIED FROM CPython 3.12 alpha (July 2022)
### Original part after ############
# cython: language_level=3
# new code
import cython
-from Cython.Compiler.Main import compile as cython_compile, CompileError
-from Cython.Build.Inline import cython_inline
-import contextlib
-from tempfile import NamedTemporaryFile
-
-@contextlib.contextmanager
-def hidden_stderr():
- try:
- from StringIO import StringIO
- except ImportError:
- from io import StringIO
-
- old_stderr = sys.stderr
- try:
- sys.stderr = StringIO()
- yield
- finally:
- sys.stderr = old_stderr
-
-def _compile(code):
- with NamedTemporaryFile(suffix='.py') as f:
- f.write(code.encode('utf8'))
- f.flush()
-
- with hidden_stderr():
- result = cython_compile(f.name, language_level=3)
- return result
+from Cython.TestUtils import py_parse_code
+
if cython.compiled:
def compile(code, name, what):
assert what == 'exec'
- result = _compile(code)
- if not result.c_file:
- raise SyntaxError('unexpected EOF') # compile is only used for testing errors
+ py_parse_code(code)
+
+
+def disable(func):
+ pass
+
############## SLIGHTLY MODIFIED ORIGINAL CODE
import array
@@ -61,9 +39,47 @@ else:
y: int
# TestCompiler removed - it's very CPython-specific
-# TestTracing also removed - doesn't seem like a core test
+# TestTracing also mainly removed - doesn't seem like a core test
+# except for one test that seems misplaced in CPython (which is below)
+
+class TestTracing(unittest.TestCase):
+ if sys.version_info < (3, 4):
+ class SubTestClass(object):
+ def __enter__(self):
+ return self
+ def __exit__(self, exc_type, exc_value, traceback):
+ return
+ def __call__(self, *args):
+ return self
+ subTest = SubTestClass()
+
+ def test_parser_deeply_nested_patterns(self):
+ # Deeply nested patterns can cause exponential backtracking when parsing.
+ # See CPython gh-93671 for more information.
+ #
+ # DW: Cython note - this doesn't break the parser but may cause a
+ # RecursionError later in the code-generation. I don't believe that's
+ # easily avoidable with the way Cython visitors currently work
+
+ levels = 100
+
+ patterns = [
+ "A" + "(" * levels + ")" * levels,
+ "{1:" * levels + "1" + "}" * levels,
+ "[" * levels + "1" + "]" * levels,
+ ]
-# FIXME - return all the "return"s added to cause code to be dropped
+ for pattern in patterns:
+ with self.subTest(pattern):
+ code = inspect.cleandoc("""
+ match None:
+ case {}:
+ pass
+ """.format(pattern))
+ compile(code, "<string>", "exec")
+
+
+# FIXME - remove all the "return"s added to cause code to be dropped
############## ORIGINAL PART FROM CPYTHON
@@ -71,7 +87,7 @@ class TestInheritance(unittest.TestCase):
@staticmethod
def check_sequence_then_mapping(x):
- return
+ return # disabled
match x:
case [*_]:
return "seq"
@@ -80,7 +96,7 @@ class TestInheritance(unittest.TestCase):
@staticmethod
def check_mapping_then_sequence(x):
- return
+ return # disabled
match x:
case {}:
return "map"
@@ -88,7 +104,7 @@ class TestInheritance(unittest.TestCase):
return "seq"
def test_multiple_inheritance_mapping(self):
- return
+ return # disabled
class C:
pass
class M1(collections.UserDict, collections.abc.Sequence):
@@ -109,7 +125,7 @@ class TestInheritance(unittest.TestCase):
self.assertEqual(self.check_mapping_then_sequence(M4()), "map")
def test_multiple_inheritance_sequence(self):
- return
+ return # disabled
class C:
pass
class S1(collections.UserList, collections.abc.Mapping):
@@ -130,7 +146,7 @@ class TestInheritance(unittest.TestCase):
self.assertEqual(self.check_mapping_then_sequence(S4()), "seq")
def test_late_registration_mapping(self):
- return
+ return # disabled
class Parent:
pass
class ChildPre(Parent):
@@ -154,7 +170,7 @@ class TestInheritance(unittest.TestCase):
self.assertEqual(self.check_mapping_then_sequence(GrandchildPost()), "map")
def test_late_registration_sequence(self):
- return
+ return # disabled
class Parent:
pass
class ChildPre(Parent):
@@ -346,7 +362,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_022(self):
- return
+ return # disabled
x = {}
match x:
case {}:
@@ -355,7 +371,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_023(self):
- return
+ return # disabled
x = {0: 0}
match x:
case {}:
@@ -364,7 +380,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_024(self):
- return
+ return # disabled
x = {}
y = None
match x:
@@ -374,7 +390,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(y, None)
def test_patma_025(self):
- return
+ return # disabled
x = {0: 0}
match x:
case {0: (0 | 1 | 2 as z)}:
@@ -384,7 +400,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_026(self):
- return
+ return # disabled
x = {0: 1}
match x:
case {0: (0 | 1 | 2 as z)}:
@@ -394,7 +410,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 1)
def test_patma_027(self):
- return
+ return # disabled
x = {0: 2}
match x:
case {0: (0 | 1 | 2 as z)}:
@@ -404,7 +420,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 2)
def test_patma_028(self):
- return
+ return # disabled
x = {0: 3}
y = None
match x:
@@ -414,7 +430,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(y, None)
def test_patma_029(self):
- return
+ return # disabled
x = {}
y = None
match x:
@@ -428,7 +444,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(y, None)
def test_patma_030(self):
- return
+ return # disabled
x = {False: (True, 2.0, {})}
match x:
case {0: [1, 2, {}]}:
@@ -441,7 +457,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_031(self):
- return
+ return # disabled
x = {False: (True, 2.0, {}), 1: [[]], 2: 0}
match x:
case {0: [1, 2, {}]}:
@@ -454,7 +470,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_032(self):
- return
+ return # disabled
x = {False: (True, 2.0, {}), 1: [[]], 2: 0}
match x:
case {0: [1, 2]}:
@@ -467,7 +483,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 1)
def test_patma_033(self):
- return
+ return # disabled
x = []
match x:
case {0: [1, 2, {}]}:
@@ -480,7 +496,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 2)
def test_patma_034(self):
- return
+ return # disabled
x = {0: 0}
match x:
case {0: [1, 2, {}]}:
@@ -493,7 +509,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 1)
def test_patma_035(self):
- return
+ return # disabled
x = {0: 0}
match x:
case {0: [1, 2, {}]}:
@@ -539,7 +555,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(y, None)
def test_patma_040(self):
- return
+ return # disabled
x = 0
match x:
case (0 as z) | (1 as z) | (2 as z) if z == x % 2:
@@ -549,7 +565,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_041(self):
- return
+ return # disabled
x = 1
match x:
case (0 as z) | (1 as z) | (2 as z) if z == x % 2:
@@ -559,7 +575,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 1)
def test_patma_042(self):
- return
+ return # disabled
x = 2
y = None
match x:
@@ -570,7 +586,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 2)
def test_patma_043(self):
- return
+ return # disabled
x = 3
y = None
match x:
@@ -612,7 +628,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_048(self):
- return
+ return # disabled
x = [0, 1]
match x:
case [0, 1] | [1, 0]:
@@ -621,7 +637,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_049(self):
- return
+ return # disabled
x = [1, 0]
match x:
case [0, 1] | [1, 0]:
@@ -630,7 +646,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_050(self):
- return
+ return # disabled
x = [0, 0]
y = None
match x:
@@ -640,7 +656,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(y, None)
def test_patma_051(self):
- return
+ return # disabled
w = None
x = [1, 0]
match x:
@@ -1012,7 +1028,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_087(self):
- return
+ return # disabled
x = 0
match x:
case (0 | 1) | 2:
@@ -1021,7 +1037,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_088(self):
- return
+ return # disabled
x = 1
match x:
case (0 | 1) | 2:
@@ -1030,7 +1046,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_089(self):
- return
+ return # disabled
x = 2
match x:
case (0 | 1) | 2:
@@ -1039,7 +1055,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_090(self):
- return
+ return # disabled
x = 3
y = None
match x:
@@ -1049,7 +1065,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(y, None)
def test_patma_091(self):
- return
+ return # disabled
x = 0
match x:
case 0 | (1 | 2):
@@ -1058,7 +1074,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_092(self):
- return
+ return # disabled
x = 1
match x:
case 0 | (1 | 2):
@@ -1067,7 +1083,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_093(self):
- return
+ return # disabled
x = 2
match x:
case 0 | (1 | 2):
@@ -1076,7 +1092,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_094(self):
- return
+ return # disabled
x = 3
y = None
match x:
@@ -1311,7 +1327,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 1)
def test_patma_119(self):
- return
+ return # disabled
x = collections.defaultdict(int)
match x:
case {0: 0}:
@@ -1322,7 +1338,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 1)
def test_patma_120(self):
- return
+ return # disabled
x = collections.defaultdict(int)
match x:
case {0: 0}:
@@ -1417,7 +1433,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_133(self):
- return
+ return # disabled
x = collections.defaultdict(int, {0: 1})
match x:
case {1: 0}:
@@ -1430,7 +1446,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 2)
def test_patma_134(self):
- return
+ return # disabled
x = collections.defaultdict(int, {0: 1})
match x:
case {1: 0}:
@@ -1444,7 +1460,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, {0: 1})
def test_patma_135(self):
- return
+ return # disabled
x = collections.defaultdict(int, {0: 1})
match x:
case {1: 0}:
@@ -1458,7 +1474,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, {})
def test_patma_136(self):
- return
+ return # disabled
x = {0: 1}
match x:
case {1: 0}:
@@ -1471,7 +1487,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 1)
def test_patma_137(self):
- return
+ return # disabled
x = {0: 1}
match x:
case {1: 0}:
@@ -1485,7 +1501,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, {0: 1})
def test_patma_138(self):
- return
+ return # disabled
x = {0: 1}
match x:
case {1: 0}:
@@ -1499,7 +1515,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, {})
def test_patma_139(self):
- return
+ return # disabled
x = False
match x:
case bool(z):
@@ -1509,7 +1525,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_140(self):
- return
+ return # disabled
x = True
match x:
case bool(z):
@@ -1519,7 +1535,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_141(self):
- return
+ return # disabled
x = bytearray()
match x:
case bytearray(z):
@@ -1529,7 +1545,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_142(self):
- return
+ return # disabled
x = b""
match x:
case bytes(z):
@@ -1539,7 +1555,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_143(self):
- return
+ return # disabled
x = {}
match x:
case dict(z):
@@ -1549,7 +1565,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_144(self):
- return
+ return # disabled
x = 0.0
match x:
case float(z):
@@ -1559,7 +1575,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_145(self):
- return
+ return # disabled
x = frozenset()
match x:
case frozenset(z):
@@ -1569,7 +1585,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_146(self):
- return
+ return # disabled
x = 0
match x:
case int(z):
@@ -1579,7 +1595,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_147(self):
- return
+ return # disabled
x = []
match x:
case list(z):
@@ -1589,7 +1605,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_148(self):
- return
+ return # disabled
x = set()
match x:
case set(z):
@@ -1599,7 +1615,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_149(self):
- return
+ return # disabled
x = ""
match x:
case str(z):
@@ -1609,7 +1625,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(z, x)
def test_patma_150(self):
- return
+ return # disabled
x = ()
match x:
case tuple(z):
@@ -1900,7 +1916,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(http_error(401 | 403 | 404), None) # 407
def test_patma_176(self):
- return
+ return # disabled
def whereis(point):
match point:
case (0, 0):
@@ -1920,7 +1936,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(whereis(42), "Not a point")
def test_patma_177(self):
- return
+ return # disabled
def whereis(point):
match point:
case Point(0, 0):
@@ -1944,7 +1960,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(whereis(42), "Not a point")
def test_patma_178(self):
- return
+ return # disabled
def whereis(point):
match point:
case Point(1, var):
@@ -1953,7 +1969,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(whereis(Point(0, 0)), None)
def test_patma_179(self):
- return
+ return # disabled
def whereis(point):
match point:
case Point(1, y=var):
@@ -1962,7 +1978,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(whereis(Point(0, 0)), None)
def test_patma_180(self):
- return
+ return # disabled
def whereis(point):
match point:
case Point(x=1, y=var):
@@ -1971,7 +1987,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(whereis(Point(0, 0)), None)
def test_patma_181(self):
- return
+ return # disabled
def whereis(point):
match point:
case Point(y=var, x=1):
@@ -1980,7 +1996,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(whereis(Point(0, 0)), None)
def test_patma_182(self):
- return
+ return # disabled
def whereis(points):
match points:
case []:
@@ -2003,7 +2019,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(whereis([Point(0, 1), Point(0, 1), Point(0, 1)]), "Something else")
def test_patma_183(self):
- return
+ return # disabled
def whereis(point):
match point:
case Point(x, y) if x == y:
@@ -2114,7 +2130,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_193(self):
- return
+ return # disabled
x = {"bandwidth": 0, "latency": 1}
match x:
case {"bandwidth": b, "latency": l}:
@@ -2125,7 +2141,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_194(self):
- return
+ return # disabled
x = {"bandwidth": 0, "latency": 1, "key": "value"}
match x:
case {"latency": l, "bandwidth": b}:
@@ -2136,7 +2152,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_195(self):
- return
+ return # disabled
x = {"bandwidth": 0, "latency": 1, "key": "value"}
match x:
case {"bandwidth": b, "latency": l, **rest}:
@@ -2148,7 +2164,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_196(self):
- return
+ return # disabled
x = {"bandwidth": 0, "latency": 1}
match x:
case {"latency": l, "bandwidth": b, **rest}:
@@ -2160,7 +2176,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_197(self):
- return
+ return # disabled
w = [Point(-1, 0), Point(1, 2)]
match w:
case (Point(x1, y1), Point(x2, y2) as p2):
@@ -2226,7 +2242,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(f(3.0), None)
def test_patma_200(self):
- return
+ return # disabled
class Class:
__match_args__ = ("a", "b")
c = Class()
@@ -2240,7 +2256,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_201(self):
- return
+ return # disabled
class Class:
__match_args__ = ("a", "b")
c = Class()
@@ -2254,7 +2270,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_202(self):
- return
+ return # disabled
class Parent:
__match_args__ = "a", "b"
class Child(Parent):
@@ -2270,7 +2286,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_203(self):
- return
+ return # disabled
class Parent:
__match_args__ = ("a", "b")
class Child(Parent):
@@ -2325,7 +2341,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(f("1"), None)
def test_patma_207(self):
- return
+ return # disabled
def f(w):
match w:
case [1, 2] | [3, 4]:
@@ -2379,7 +2395,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(f(bytearray(b"abc")), None)
def test_patma_211(self):
- return
+ return # disabled
def f(w):
match w:
case {"x": x, "y": "y", "z": z}:
@@ -2392,7 +2408,7 @@ class TestPatma(unittest.TestCase):
self.assertIs(f(({"x": "x", "y": "y"})), None)
def test_patma_212(self):
- return
+ return # disabled
def f(w):
match w:
case Point(int(xx), y="hello"):
@@ -2449,7 +2465,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(set(f()), {"a", "b"})
def test_patma_219(self):
- return
+ return # disabled
def f():
match {"k": ..., "l": ...}:
case {"k": a, "l": b}:
@@ -2457,7 +2473,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(set(f()), {"a", "b"})
def test_patma_220(self):
- return
+ return # disabled
def f():
match Point(..., ...):
case Point(x, y=y):
@@ -2653,7 +2669,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, (2, 3))
def test_patma_239(self):
- return
+ return # disabled
x = collections.UserDict({0: 1, 2: 3})
match x:
case {2: 3}:
@@ -2662,7 +2678,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 0)
def test_patma_240(self):
- return
+ return # disabled
x = collections.UserDict({0: 1, 2: 3})
match x:
case {2: 3, **z}:
@@ -2672,7 +2688,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, {0: 1})
def test_patma_241(self):
- return
+ return # disabled
x = [[{0: 0}]]
match x:
case list([({-0-0j: int(real=0+0j, imag=0-0j) | (1) as z},)]):
@@ -2710,7 +2726,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_245(self):
- return
+ return # disabled
x = {"y": 1}
match x:
case {"y": (0 as y) | (1 as y)}:
@@ -2720,7 +2736,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(z, 0)
def test_patma_246(self):
- return
+ return # disabled
def f(x):
match x:
case ((a, b, c, d, e, f, g, h, i, 9) |
@@ -2745,7 +2761,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(f(range(10, 20)), alts[4])
def test_patma_247(self):
- return
+ return # disabled
def f(x):
match x:
case [y, (a, b, c, d, e, f, g, h, i, 9) |
@@ -2770,7 +2786,7 @@ class TestPatma(unittest.TestCase):
self.assertEqual(f((False, range(10, 20), True)), alts[4])
def test_patma_248(self):
- return
+ return # disabled
class C(dict):
@staticmethod
def get(key, default=None):
@@ -2783,6 +2799,21 @@ class TestPatma(unittest.TestCase):
self.assertEqual(y, 'bar')
+ def test_patma_249(self):
+ return # disabled
+ class C:
+ __attr = "eggs" # mangled to _C__attr
+ _Outer__attr = "bacon"
+ class Outer:
+ def f(self, x):
+ match x:
+ # looks up __attr, not _C__attr or _Outer__attr
+ case C(__attr=y):
+ return y
+ c = C()
+ setattr(c, "__attr", "spam") # setattr is needed because we're in a class scope
+ self.assertEqual(Outer().f(c), "spam")
+
class TestSyntaxErrors(unittest.TestCase):
@@ -2805,6 +2836,7 @@ class TestSyntaxErrors(unittest.TestCase):
""")
+ @disable # validation will be added when class patterns are added
def test_attribute_name_repeated_in_class_pattern(self):
self.assert_syntax_error("""
match ...:
@@ -2903,6 +2935,7 @@ class TestSyntaxErrors(unittest.TestCase):
pass
""")
+ @disable # will be implemented as part of sequence patterns
def test_multiple_starred_names_in_sequence_pattern_0(self):
self.assert_syntax_error("""
match ...:
@@ -2910,6 +2943,7 @@ class TestSyntaxErrors(unittest.TestCase):
pass
""")
+ @disable # will be implemented as part of sequence patterns
def test_multiple_starred_names_in_sequence_pattern_1(self):
self.assert_syntax_error("""
match ...:
@@ -3044,6 +3078,7 @@ class TestSyntaxErrors(unittest.TestCase):
pass
""")
+ @disable # validation will be added when class patterns are added
def test_mapping_pattern_duplicate_key(self):
self.assert_syntax_error("""
match ...:
@@ -3051,6 +3086,7 @@ class TestSyntaxErrors(unittest.TestCase):
pass
""")
+ @disable # validation will be added when class patterns are added
def test_mapping_pattern_duplicate_key_edge_case0(self):
self.assert_syntax_error("""
match ...:
@@ -3058,6 +3094,7 @@ class TestSyntaxErrors(unittest.TestCase):
pass
""")
+ @disable # validation will be added when class patterns are added
def test_mapping_pattern_duplicate_key_edge_case1(self):
self.assert_syntax_error("""
match ...:
@@ -3065,6 +3102,7 @@ class TestSyntaxErrors(unittest.TestCase):
pass
""")
+ @disable # validation will be added when class patterns are added
def test_mapping_pattern_duplicate_key_edge_case2(self):
self.assert_syntax_error("""
match ...:
@@ -3072,6 +3110,7 @@ class TestSyntaxErrors(unittest.TestCase):
pass
""")
+ @disable # validation will be added when class patterns are added
def test_mapping_pattern_duplicate_key_edge_case3(self):
self.assert_syntax_error("""
match ...:
@@ -3082,7 +3121,7 @@ class TestSyntaxErrors(unittest.TestCase):
class TestTypeErrors(unittest.TestCase):
def test_accepts_positional_subpatterns_0(self):
- return
+ return # disabled
class Class:
__match_args__ = ()
x = Class()
@@ -3095,7 +3134,7 @@ class TestTypeErrors(unittest.TestCase):
self.assertIs(z, None)
def test_accepts_positional_subpatterns_1(self):
- return
+ return # disabled
x = range(10)
y = None
with self.assertRaises(TypeError):
@@ -3106,7 +3145,7 @@ class TestTypeErrors(unittest.TestCase):
self.assertIs(y, None)
def test_got_multiple_subpatterns_for_attribute_0(self):
- return
+ return # disabled
class Class:
__match_args__ = ("a", "a")
a = None
@@ -3121,7 +3160,7 @@ class TestTypeErrors(unittest.TestCase):
self.assertIs(z, None)
def test_got_multiple_subpatterns_for_attribute_1(self):
- return
+ return # disabled
class Class:
__match_args__ = ("a",)
a = None
@@ -3136,7 +3175,7 @@ class TestTypeErrors(unittest.TestCase):
self.assertIs(z, None)
def test_match_args_elements_must_be_strings(self):
- return
+ return # disabled
class Class:
__match_args__ = (None,)
x = Class()
@@ -3149,7 +3188,7 @@ class TestTypeErrors(unittest.TestCase):
self.assertIs(z, None)
def test_match_args_must_be_a_tuple_0(self):
- return
+ return # disabled
class Class:
__match_args__ = None
x = Class()
@@ -3162,7 +3201,7 @@ class TestTypeErrors(unittest.TestCase):
self.assertIs(z, None)
def test_match_args_must_be_a_tuple_1(self):
- return
+ return # disabled
class Class:
__match_args__ = "XYZ"
x = Class()
@@ -3175,7 +3214,7 @@ class TestTypeErrors(unittest.TestCase):
self.assertIs(z, None)
def test_match_args_must_be_a_tuple_2(self):
- return
+ return # disabled
class Class:
__match_args__ = ["spam", "eggs"]
spam = 0
@@ -3194,7 +3233,7 @@ class TestTypeErrors(unittest.TestCase):
class TestValueErrors(unittest.TestCase):
def test_mapping_pattern_checks_duplicate_key_1(self):
- return
+ return # disabled
class Keys:
KEY = "a"
x = {"a": 0, "b": 1}