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
13import unittest
24
35from immutables .map import Map as PyMap
@@ -7,14 +9,25 @@ class BaseMapTest:
79
810 Map = None
911
12+ @unittest .skipIf (
13+ sys .version_info < (3 , 10 ),
14+ "pattern matching is not supported in this Python version" ,
15+ )
1016 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+ )
1831
1932
2033class PyMapTest (BaseMapTest , unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments