add LogEntry.__eq__

This commit is contained in:
Maximilian Hils 2017-08-01 13:41:48 +02:00
parent 864073f700
commit e8f836425a
2 changed files with 10 additions and 0 deletions

View File

@ -4,6 +4,11 @@ class LogEntry:
self.msg = msg
self.level = level
def __eq__(self, other):
if isinstance(other, LogEntry):
return self.__dict__ == other.__dict__
return False
def __repr__(self):
return "LogEntry({}, {})".format(self.msg, self.level)

View File

@ -4,3 +4,8 @@ from mitmproxy import log
def test_logentry():
e = log.LogEntry("foo", "info")
assert repr(e) == "LogEntry(foo, info)"
f = log.LogEntry("foo", "warning")
assert e == e
assert e != f
assert e != 42