Skip to content

Instantly share code, notes, and snippets.

@avalanchy
Created May 2, 2017 08:38
Show Gist options
  • Save avalanchy/ecc4ba30d7c763bcaadefc5a7d540aec to your computer and use it in GitHub Desktop.
Save avalanchy/ecc4ba30d7c763bcaadefc5a7d540aec to your computer and use it in GitHub Desktop.
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