mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2024-11-23 13:19:48 +00:00
logging: don't pick up later mutations
This commit is contained in:
parent
d6975e0b80
commit
2fe4a49d8f
@ -6,7 +6,9 @@ from mitmproxy import hooks
|
||||
|
||||
class LogEntry:
|
||||
def __init__(self, msg, level):
|
||||
self.msg = msg
|
||||
# it's important that we serialize to string here already so that we don't pick up changes
|
||||
# happening after this log statement.
|
||||
self.msg = str(msg)
|
||||
self.level = level
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -9,3 +9,10 @@ def test_logentry():
|
||||
assert e == e
|
||||
assert e != f
|
||||
assert e != 42
|
||||
|
||||
|
||||
def test_dont_pick_up_mutations():
|
||||
x = {"foo": "bar"}
|
||||
e = log.LogEntry(x, "info")
|
||||
x["foo"] = "baz" # this should not affect the log entry anymore.
|
||||
assert repr(e) == "LogEntry({'foo': 'bar'}, info)"
|
||||
|
Loading…
Reference in New Issue
Block a user