-
-
Save isidentical/0bfc74c21d351a87ae933087fd36304d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
re.match(case) | |
case = something | |
import case | |
from match import case | |
# case black_test_patma_225 | |
def test_patma_225(self): | |
def f(x): | |
match x: | |
case 0: | |
return 0 | |
case 1: | |
return 1 | |
self.assertEqual(f(0), 0) | |
self.assertEqual(f(1), 1) | |
self.assertIs(f(2), None) | |
self.assertIs(f(3), None) | |
# case black_test_patma_170 | |
def test_patma_170(self): | |
x = 0 | |
match x: | |
case _ if not x: | |
y = 0 | |
case 0: | |
y = 1 | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 0) | |
# case black_test_patma_188 | |
def test_patma_188(self): | |
w = range(100) | |
match w: | |
case (x, y, *rest): | |
z = 0 | |
self.assertEqual(w, range(100)) | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 1) | |
self.assertEqual(z, 0) | |
self.assertEqual(rest, list(range(2, 100))) | |
re.match(case) | |
case = something | |
import case | |
from match import case | |
# case black_test_patma_128 | |
def test_patma_128(self): | |
match (0, 1, 2): | |
case *x, 0, 1, 2,: | |
y = 0 | |
self.assertEqual(x, []) | |
self.assertEqual(y, 0) | |
# case black_test_patma_070 | |
def test_patma_070(self): | |
x = 0 | |
match x: | |
case 0 if True: | |
y = 0 | |
case 0 if True: | |
y = 1 | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 0) | |
# case black_test_multiple_starred_names_in_sequence_pattern_1 | |
def test_multiple_starred_names_in_sequence_pattern_1(self): | |
self.assert_syntax_error(""" | |
match ...: | |
case a, *b, c, *d, e: | |
pass | |
""") | |
# case black_test_patma_173 | |
def test_patma_173(self): | |
x = 0 | |
match x: | |
case _ if not x: | |
y = 0 | |
case _: | |
y = 1 | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 0) | |
# case black_test_patma_048 | |
def test_patma_048(self): | |
x = [0, 1] | |
match x: | |
case [0, 1] | [1, 0]: | |
y = 0 | |
self.assertEqual(x, [0, 1]) | |
self.assertEqual(y, 0) | |
# case black_test_patma_037 | |
def test_patma_037(self): | |
x = 1 | |
match x: | |
case 0 | 1 | 2: | |
y = 0 | |
self.assertEqual(x, 1) | |
self.assertEqual(y, 0) | |
re.match(case) | |
case = something | |
import case | |
from match import case | |
# case black_test_patma_131 | |
def test_patma_131(self): | |
match (0, 1, 2): | |
case (0, *x, 1, 2): | |
y = 0 | |
self.assertEqual(x, []) | |
self.assertEqual(y, 0) | |
# case black_test_patma_240 | |
def test_patma_240(self): | |
x = collections.UserDict({0: 1, 2: 3}) | |
match x: | |
case {2: 3, **z}: | |
y = 0 | |
self.assertEqual(x, {0: 1, 2: 3}) | |
self.assertEqual(y, 0) | |
self.assertEqual(z, {0: 1}) | |
# case black_test_patma_184 | |
def test_patma_184(self): | |
class Seq(collections.abc.Sequence): | |
__getitem__ = None | |
def __len__(self): | |
return 0 | |
match Seq(): | |
case []: | |
y = 0 | |
self.assertEqual(y, 0) | |
# case black_test_patma_238 | |
def test_patma_238(self): | |
x = ((0, 1), (2, 3)) | |
match x: | |
case ((a as b, c as d) as e) as w, ((f as g, h) as i) as z: | |
y = 0 | |
self.assertEqual(a, 0) | |
self.assertEqual(b, 0) | |
self.assertEqual(c, 1) | |
self.assertEqual(d, 1) | |
self.assertEqual(e, (0, 1)) | |
self.assertEqual(f, 2) | |
self.assertEqual(g, 2) | |
self.assertEqual(h, 3) | |
self.assertEqual(i, (2, 3)) | |
self.assertEqual(w, (0, 1)) | |
self.assertEqual(x, ((0, 1), (2, 3))) | |
self.assertEqual(y, 0) | |
self.assertEqual(z, (2, 3)) | |
# case black_test_patma_228 | |
def test_patma_228(self): | |
match(): | |
case(): | |
x = 0 | |
self.assertEqual(x, 0) | |
# case black_test_patma_160 | |
def test_patma_160(self): | |
x = 0 | |
z = None | |
match x: | |
case 0: | |
y = 0 | |
case z if x: | |
y = 1 | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 0) | |
self.assertIs(z, None) | |
re.match(case) | |
case = something | |
import case | |
from match import case | |
# case black_test_patma_083 | |
def test_patma_083(self): | |
x = 0 | |
match x: | |
case (0 as z): | |
y = 0 | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 0) | |
self.assertEqual(z, 0) | |
# case black_test_patma_009 | |
def test_patma_009(self): | |
class A: | |
B = 0 | |
match 0: | |
case x if x: | |
z = 0 | |
case _ as y if y == x and y: | |
z = 1 | |
case A.B: | |
z = 2 | |
self.assertEqual(A.B, 0) | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 0) | |
self.assertEqual(z, 2) | |
# case black_test_patma_089 | |
def test_patma_089(self): | |
x = 2 | |
match x: | |
case (0 | 1) | 2: | |
y = 0 | |
self.assertEqual(x, 2) | |
self.assertEqual(y, 0) | |
re.match(case) | |
case = something | |
import case | |
from match import case | |
# case black_test_patma_174 | |
def test_patma_174(self): | |
def http_error(status): | |
match status: | |
case 400: | |
return "Bad request" | |
case 401: | |
return "Unauthorized" | |
case 403: | |
return "Forbidden" | |
case 404: | |
return "Not found" | |
case 418: | |
return "I'm a teapot" | |
case _: | |
return "Something else" | |
self.assertEqual(http_error(400), "Bad request") | |
self.assertEqual(http_error(401), "Unauthorized") | |
self.assertEqual(http_error(403), "Forbidden") | |
self.assertEqual(http_error(404), "Not found") | |
self.assertEqual(http_error(418), "I'm a teapot") | |
self.assertEqual(http_error(123), "Something else") | |
self.assertEqual(http_error("400"), "Something else") | |
self.assertEqual(http_error(401 | 403 | 404), "Something else") | |
# case black_test_real_number_required_in_complex_literal_3 | |
def test_real_number_required_in_complex_literal_3(self): | |
self.assert_syntax_error(""" | |
match ...: | |
case {0j+0j: _}: | |
pass | |
""") | |
# case black_test_patma_237 | |
def test_patma_237(self): | |
x = 0 | |
match x: | |
case (0 as w) as z: | |
y = 0 | |
self.assertEqual(w, 0) | |
self.assertEqual(x, 0) | |
self.assertEqual(y, 0) | |
self.assertEqual(z, 0) | |
# case black_test_patma_094 | |
def test_patma_094(self): | |
x = 3 | |
y = None | |
match x: | |
case 0 | (1 | 2): | |
y = 0 | |
self.assertEqual(x, 3) | |
self.assertIs(y, None) | |
# case black_test_patma_123 | |
def test_patma_123(self): | |
match (0, 1, 2): | |
case 0, *x: | |
y = 0 | |
self.assertEqual(x, [1, 2]) | |
self.assertEqual(y, 0) | |
# case black_test_patma_010 | |
def test_patma_010(self): | |
match (): | |
case []: | |
x = 0 | |
self.assertEqual(x, 0) | |
re.match(case) | |
case = something | |
import case | |
from match import case | |
re.match(case) | |
case = something | |
import case | |
from match import case | |
from match import case |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment