File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change
1
+ import sys
2
+ import textwrap
1
3
import unittest
2
4
3
5
from immutables .map import Map as PyMap
@@ -7,14 +9,25 @@ class BaseMapTest:
7
9
8
10
Map = None
9
11
12
+ @unittest .skipIf (
13
+ sys .version_info < (3 , 10 ),
14
+ "pattern matching is not supported in this Python version" ,
15
+ )
10
16
def test_map_can_be_matched (self ):
11
- match self .Map (a = 1 , b = 2 ): # noqa: E999
12
- case {"a" : 1 as matched }:
13
- matched = matched
14
- case _:
15
- assert False
16
-
17
- assert matched == 1
17
+ 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
+ )
18
31
19
32
20
33
class PyMapTest (BaseMapTest , unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments