matchers.py 514 B

12345678910111213141516
  1. import sys
  2. import typing
  3. import types
  4. class HasAttributes(types.SimpleNamespace):
  5. def __eq__(self, other: typing.Any) -> bool:
  6. for key, value in vars(self).items():
  7. if not hasattr(other, key):
  8. print(f"Where there is no value at {key}", file=sys.stderr)
  9. return False
  10. if value != getattr(other, key):
  11. print(f"Where the value at {key} is '{getattr(other, key)}'", file=sys.stderr)
  12. return False
  13. return True