41
41
import inspect
42
42
43
43
44
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
45
44
def test_guard ():
46
45
def f (x , g ):
47
46
match x :
@@ -63,7 +62,6 @@ def f(x):
63
62
assert f (1 ) == 42
64
63
assert f (2 ) == 0
65
64
66
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
67
65
def test_complex_as_binary_op ():
68
66
src = """
69
67
def f(a):
@@ -88,8 +86,6 @@ def f(a):
88
86
assert f (6 + 3j ) == "match add"
89
87
assert f (- 2 - 3j ) == "match sub"
90
88
91
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
92
- @unittest .skipIf (os .environ .get ('BYTECODE_DSL_INTERPRETER' ), "TODO: mapping pattern matching" )
93
89
def test_long_mapping ():
94
90
def f (x ):
95
91
match d :
@@ -108,7 +104,6 @@ def star_match(x):
108
104
109
105
assert star_match (d ) == {33 :33 }
110
106
111
- @unittest .skipIf (os .environ .get ('BYTECODE_DSL_INTERPRETER' ), "TODO: mapping pattern matching" )
112
107
def test_mutable_dict_keys ():
113
108
class MyObj :
114
109
pass
@@ -127,7 +122,6 @@ def test(name):
127
122
assert test ('attr1' ) == {'dyn_match' : 1 , 'attr2' : 2 , 'attr3' : 3 }
128
123
assert test ('attr2' ) == {'dyn_match' : 2 , 'attr1' : 1 , 'attr3' : 3 }
129
124
130
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
131
125
def test_multiple_or_pattern_basic ():
132
126
match 0 :
133
127
case 0 | 1 | 2 | 3 | 4 | 5 as x :
@@ -137,7 +131,6 @@ def test_multiple_or_pattern_basic():
137
131
case ((0 | 1 | 2 ) as x ) | ((3 | 4 | 5 ) as x ):
138
132
assert x == 3
139
133
140
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
141
134
def test_sequence_pattern ():
142
135
match (1 , 2 ):
143
136
case (3 , 2 ):
@@ -152,7 +145,6 @@ def test_sequence_pattern():
152
145
assert False
153
146
154
147
155
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
156
148
def test_multiple_or_pattern_advanced ():
157
149
match 4 :
158
150
case (0 as z ) | (1 as z ) | (2 as z ) | (4 as z ) | (77 as z ):
@@ -187,7 +179,6 @@ def test_multiple_or_pattern_advanced():
187
179
assert w == 1
188
180
189
181
190
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
191
182
def test_multiple_or_pattern_creates_locals ():
192
183
match (1 , 2 ):
193
184
case (a , 1 ) | (a , 2 ):
@@ -238,39 +229,34 @@ def assert_syntax_error(self, code: str):
238
229
with self .assertRaises (SyntaxError ):
239
230
compile (inspect .cleandoc (code ), "<test>" , "exec" )
240
231
241
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
242
232
def test_alternative_patterns_bind_different_names_0 (self ):
243
233
self .assert_syntax_error ("""
244
234
match ...:
245
235
case "a" | a:
246
236
pass
247
237
""" )
248
238
249
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
250
239
def test_alternative_patterns_bind_different_names_1 (self ):
251
240
self .assert_syntax_error ("""
252
241
match ...:
253
242
case [a, [b] | [c] | [d]]:
254
243
pass
255
244
""" )
256
245
257
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
258
246
def test_multiple_or_same_name (self ):
259
247
self .assert_syntax_error ("""
260
248
match 0:
261
249
case x | x:
262
250
pass
263
251
""" )
264
252
265
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
266
253
def test_multiple_or_wildcard (self ):
267
254
self .assert_syntax_error ("""
268
255
match 0:
269
256
case * | 1:
270
257
pass
271
258
""" )
272
259
273
- @unittest .skipIf (sys .version_info .minor < 10 , "Requires Python 3.10+" )
274
260
def test_unbound_local_variable (self ):
275
261
with self .assertRaises (UnboundLocalError ):
276
262
match (1 , 3 ):
0 commit comments