diff --git a/mitmproxy/log.py b/mitmproxy/log.py index 886b14492..3083a000f 100644 --- a/mitmproxy/log.py +++ b/mitmproxy/log.py @@ -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) diff --git a/test/mitmproxy/test_log.py b/test/mitmproxy/test_log.py index cde679edf..349e3ac86 100644 --- a/test/mitmproxy/test_log.py +++ b/test/mitmproxy/test_log.py @@ -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