[svn r57565] also introduce config.maketrace(name, flush=False) which

returns either a nulltracer or opens a log in the tracedir
and returns an object that you can call with args to print
into the file.

--HG--
branch : trunk
This commit is contained in:
hpk
2008-08-21 19:39:34 +02:00
parent bf42c88e48
commit 7adfbfa166
2 changed files with 43 additions and 1 deletions

View File

@@ -201,13 +201,28 @@ class TestSessionAndOptions:
s = eventlog.read()
assert s.find("TestrunStart") != -1
def test_tracedir(self):
def test_tracedir_tracer(self):
tracedir = self.tmpdir.mkdir("tracedir")
config = py.test.config._reparse([self.tmpdir,
'--tracedir=%s' % tracedir])
assert config.gettracedir() == tracedir
trace = config.maketrace("trace1.log", flush=True)
trace("hello", "world")
class A: pass
trace(A())
p = tracedir.join("trace1.log")
lines = p.readlines(cr=0)
assert lines[0] == "hello world"
assert lines[1].find("A") != -1
trace.close()
def test_trace_null(self):
config = py.test.config._reparse([self.tmpdir])
assert config.gettracedir() is None
trace = config.maketrace("hello", flush=True)
trace("hello", "world")
trace.close()
def test_implied_dsession(self):
for x in 'startserver runbrowser rest'.split():