-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable support for pattern matching (#96)
- Loading branch information
1 parent
f3c0451
commit 7071a24
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import unittest | ||
|
||
from immutables.map import Map as PyMap | ||
|
||
|
||
class BaseMapTest: | ||
|
||
Map = None | ||
|
||
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 | ||
|
||
assert matched == 1 | ||
|
||
|
||
class PyMapTest(BaseMapTest, unittest.TestCase): | ||
|
||
Map = PyMap | ||
|
||
|
||
try: | ||
from immutables._map import Map as CMap | ||
except ImportError: | ||
CMap = None | ||
|
||
|
||
@unittest.skipIf(CMap is None, 'C Map is not available') | ||
class CMapTest(BaseMapTest, unittest.TestCase): | ||
|
||
Map = CMap | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |