Skip to content

Commit 2a8e12a

Browse files
committed
make test_patma work (might revert this if we get rid of the tmp vars)
1 parent 1a61812 commit 2a8e12a

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Lib/test/test_patma.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,7 @@ def test_patma_204(self):
21722172
def f(w):
21732173
match w:
21742174
case 42:
2175-
out = locals()
2175+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
21762176
del out["w"]
21772177
return out
21782178
self.assertEqual(f(42), {})
@@ -2184,7 +2184,7 @@ def test_patma_205(self):
21842184
def f(w):
21852185
match w:
21862186
case 42.0:
2187-
out = locals()
2187+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
21882188
del out["w"]
21892189
return out
21902190
self.assertEqual(f(42.0), {})
@@ -2196,7 +2196,7 @@ def test_patma_206(self):
21962196
def f(w):
21972197
match w:
21982198
case 1 | 2 | 3:
2199-
out = locals()
2199+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22002200
del out["w"]
22012201
return out
22022202
self.assertEqual(f(1), {})
@@ -2211,7 +2211,7 @@ def test_patma_207(self):
22112211
def f(w):
22122212
match w:
22132213
case [1, 2] | [3, 4]:
2214-
out = locals()
2214+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22152215
del out["w"]
22162216
return out
22172217
self.assertEqual(f([1, 2]), {})
@@ -2225,7 +2225,7 @@ def test_patma_208(self):
22252225
def f(w):
22262226
match w:
22272227
case x:
2228-
out = locals()
2228+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22292229
del out["w"]
22302230
return out
22312231
self.assertEqual(f(42), {"x": 42})
@@ -2236,7 +2236,7 @@ def test_patma_209(self):
22362236
def f(w):
22372237
match w:
22382238
case _:
2239-
out = locals()
2239+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22402240
del out["w"]
22412241
return out
22422242
self.assertEqual(f(42), {})
@@ -2247,7 +2247,7 @@ def test_patma_210(self):
22472247
def f(w):
22482248
match w:
22492249
case (x, y, z):
2250-
out = locals()
2250+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22512251
del out["w"]
22522252
return out
22532253
self.assertEqual(f((1, 2, 3)), {"x": 1, "y": 2, "z": 3})
@@ -2264,7 +2264,7 @@ def test_patma_211(self):
22642264
def f(w):
22652265
match w:
22662266
case {"x": x, "y": "y", "z": z}:
2267-
out = locals()
2267+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22682268
del out["w"]
22692269
return out
22702270
self.assertEqual(f({"x": "x", "y": "y", "z": "z"}), {"x": "x", "z": "z"})
@@ -2276,7 +2276,7 @@ def test_patma_212(self):
22762276
def f(w):
22772277
match w:
22782278
case Point(int(xx), y="hello"):
2279-
out = locals()
2279+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22802280
del out["w"]
22812281
return out
22822282
self.assertEqual(f(Point(42, "hello")), {"xx": 42})
@@ -2285,7 +2285,7 @@ def test_patma_213(self):
22852285
def f(w):
22862286
match w:
22872287
case (p, q) as x:
2288-
out = locals()
2288+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
22892289
del out["w"]
22902290
return out
22912291
self.assertEqual(f((1, 2)), {"p": 1, "q": 2, "x": (1, 2)})
@@ -2297,56 +2297,56 @@ def test_patma_214(self):
22972297
def f():
22982298
match 42:
22992299
case 42:
2300-
return locals()
2300+
return [l for l in locals() if not l.startswith('$')]
23012301
self.assertEqual(set(f()), set())
23022302

23032303
def test_patma_215(self):
23042304
def f():
23052305
match 1:
23062306
case 1 | 2 | 3:
2307-
return locals()
2307+
return [l for l in locals() if not l.startswith('$')]
23082308
self.assertEqual(set(f()), set())
23092309

23102310
def test_patma_216(self):
23112311
def f():
23122312
match ...:
23132313
case _:
2314-
return locals()
2314+
return [l for l in locals() if not l.startswith('$')]
23152315
self.assertEqual(set(f()), set())
23162316

23172317
def test_patma_217(self):
23182318
def f():
23192319
match ...:
23202320
case abc:
2321-
return locals()
2321+
return [l for l in locals() if not l.startswith('$')]
23222322
self.assertEqual(set(f()), {"abc"})
23232323

23242324
def test_patma_218(self):
23252325
def f():
23262326
match ..., ...:
23272327
case a, b:
2328-
return locals()
2328+
return [l for l in locals() if not l.startswith('$')]
23292329
self.assertEqual(set(f()), {"a", "b"})
23302330

23312331
def test_patma_219(self):
23322332
def f():
23332333
match {"k": ..., "l": ...}:
23342334
case {"k": a, "l": b}:
2335-
return locals()
2335+
return [l for l in locals() if not l.startswith('$')]
23362336
self.assertEqual(set(f()), {"a", "b"})
23372337

23382338
def test_patma_220(self):
23392339
def f():
23402340
match Point(..., ...):
23412341
case Point(x, y=y):
2342-
return locals()
2342+
return [l for l in locals() if not l.startswith('$')]
23432343
self.assertEqual(set(f()), {"x", "y"})
23442344

23452345
def test_patma_221(self):
23462346
def f():
23472347
match ...:
23482348
case b as a:
2349-
return locals()
2349+
return [l for l in locals() if not l.startswith('$')]
23502350
self.assertEqual(set(f()), {"a", "b"})
23512351

23522352
def test_patma_222(self):
@@ -2601,7 +2601,7 @@ def f(x):
26012601
(g, b, a, c, d, -5, e, h, i, f) |
26022602
(-1, d, f, b, g, e, i, a, h, c)):
26032603
w = 0
2604-
out = locals()
2604+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
26052605
del out["x"]
26062606
return out
26072607
alts = [
@@ -2625,7 +2625,7 @@ def f(x):
26252625
(g, b, a, c, d, -5, e, h, i, f) |
26262626
(-1, d, f, b, g, e, i, a, h, c), z]:
26272627
w = 0
2628-
out = locals()
2628+
out = {k : v for k,v in locals().items() if not k.startswith('$')}
26292629
del out["x"]
26302630
return out
26312631
alts = [

0 commit comments

Comments
 (0)