We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f5861c commit 2c4e7a6Copy full SHA for 2c4e7a6
1 file changed
tests/test_pattern_matching.py
@@ -1,3 +1,5 @@
1
+import sys
2
+import textwrap
3
import unittest
4
5
from immutables.map import Map as PyMap
@@ -7,14 +9,25 @@ class BaseMapTest:
7
9
8
10
Map = None
11
12
+ @unittest.skipIf(
13
+ sys.version_info < (3, 10),
14
+ "pattern matching is not supported in this Python version",
15
+ )
16
def test_map_can_be_matched(self):
- match self.Map(a=1, b=2): # noqa: E999
- case {"a": 1 as matched}:
- matched = matched
- case _:
- assert False
-
17
- assert matched == 1
+ locals_ = dict(locals())
18
+ exec(
19
+ textwrap.dedent("""\
20
+ match self.Map(a=1, b=2): # noqa: E999
21
+ case {"a": 1 as matched}:
22
+ matched = matched
23
+ case _:
24
+ assert False
25
+
26
+ self.assertEqual(matched, 1)
27
+ """),
28
+ globals(),
29
+ locals_,
30
31
32
33
class PyMapTest(BaseMapTest, unittest.TestCase):
0 commit comments