From 4ca62e0d9bd09aa286cde9bafceff7204304d00c Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 5 Jun 2015 11:42:06 +1200 Subject: [PATCH] tcp: clear_log to clear socket logs --- netlib/tcp.py | 3 +++ test/test_tcp.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/netlib/tcp.py b/netlib/tcp.py index f6179faa6..2ebfae963 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -126,6 +126,9 @@ class _FileLike(object): if self.is_logging(): self._log.append(v) + def clear_log(self): + self._log = [] + def reset_timestamps(self): self.first_byte_timestamp = None diff --git a/test/test_tcp.py b/test/test_tcp.py index 14ba555d5..362ba0f40 100644 --- a/test/test_tcp.py +++ b/test/test_tcp.py @@ -553,6 +553,8 @@ class TestFileLike: assert s.get_log() == "" s.read(1) assert s.get_log() == "o" + s.clear_log() + assert s.get_log() == "" s.stop_log() tutils.raises(ValueError, s.get_log)