Last active
July 9, 2018 02:30
-
-
Save aodag/8dee67b261d21cd209b8f89bf87db087 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
""" | |
>>> v = {"a": 1, "b": 2} | |
>>> assert v == {"a": 1, "b": Any()} | |
>>> assert v == {"a": 1, "b": IsA(int)} | |
""" | |
class Any: | |
def __eq__(self, o): | |
return True | |
class NotNone: | |
def __eq__(self, o): | |
return o is not None | |
class IsTrue: | |
def __eq__(self, o): | |
return bool(o) | |
class IsA: | |
def __init__(self, typ): | |
self.typ = typ | |
def __eq__(self, o): | |
return isinstance(o, self.typ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment