Created
May 2, 2017 08:38
-
-
Save avalanchy/ecc4ba30d7c763bcaadefc5a7d540aec 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
class InstanceOf: | |
"""Wrapper to compare only type, not whole instance. | |
Example usage: | |
def test_ok(m_ted): | |
... | |
m_ted.assert_called_once_with(InstanceOf(NotificationRequest)) | |
""" | |
def __init__(self, class_): | |
self.class_ = class_ | |
def __eq__(self, other): | |
return isinstance(other, self.class_) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment