Tweak test log formatting to match adapter logs, and reset session ID between tests.

This commit is contained in:
Pavel Minaev 2019-12-06 13:41:20 -08:00 committed by Pavel Minaev
parent b23031b773
commit a3acba68d5
4 changed files with 13 additions and 6 deletions

View file

@ -23,7 +23,7 @@ class BackChannel(object):
self._server_socket = None
def __str__(self):
return fmt("BackChannel-{0}", self.session.id)
return fmt("BackChannel[{0}]", self.session.id)
def listen(self):
self._server_socket = sockets.create_server("127.0.0.1", 0, self.TIMEOUT)

View file

@ -26,7 +26,7 @@ class CapturedOutput(object):
self._capture(fd, stream_name)
def __str__(self):
return fmt("CapturedOutput({0})", self.session)
return fmt("CapturedOutput[{0}]", self.session.id)
def _worker(self, fd, name):
chunks = self._chunks[name]

View file

@ -74,7 +74,9 @@ class Session(object):
Automatically set to tmpdir for the current test by pytest_fixtures.test_wrapper().
"""
_counter = itertools.count(1)
@classmethod
def reset_counter(cls):
cls._counter = itertools.count(1)
def __init__(self, debug_config=None):
assert Session.tmpdir is not None
@ -192,15 +194,15 @@ class Session(object):
self.spawn_debuggee.env = util.Env()
def __str__(self):
return fmt("Session-{0}", self.id)
return fmt("Session[{0}]", self.id)
@property
def adapter_id(self):
return fmt("Adapter-{0}", self.id)
return fmt("Adapter[{0}]", self.id)
@property
def debuggee_id(self):
return fmt("Debuggee-{0}", self.id)
return fmt("Debuggee[{0}]", self.id)
def __enter__(self):
return self
@ -799,3 +801,6 @@ class Session(object):
pass
self.channel.wait()
self.channel = None
Session.reset_counter()

View file

@ -45,6 +45,8 @@ def test_wrapper(request, long_tmpdir):
with open(filename, "wb") as f:
f.write(data)
session.Session.reset_counter()
session.Session.tmpdir = long_tmpdir
original_log_dir = options.log_dir