parent
0dbe04abcb
commit
a6f1e3d82f
|
@ -226,16 +226,17 @@ class Config(object):
|
|||
if self.option.tracedir is not None:
|
||||
return py.path.local(self.option.tracedir)
|
||||
|
||||
def maketrace(self, name, flush=False):
|
||||
def maketrace(self, name, flush=True):
|
||||
""" return a tracedirectory or None, depending on --tracedir. """
|
||||
tracedir = self.gettracedir()
|
||||
if tracedir is None:
|
||||
return NullTracer()
|
||||
tracedir.ensure(dir=1)
|
||||
return Tracer(tracedir.join(name), flush=flush)
|
||||
|
||||
class Tracer(object):
|
||||
file = None
|
||||
def __init__(self, path, flush=False):
|
||||
def __init__(self, path, flush=True):
|
||||
self.file = path.open(mode='w')
|
||||
self.flush = flush
|
||||
|
||||
|
|
|
@ -202,12 +202,12 @@ class TestSessionAndOptions:
|
|||
assert s.find("TestrunStart") != -1
|
||||
|
||||
def test_tracedir_tracer(self):
|
||||
tracedir = self.tmpdir.mkdir("tracedir")
|
||||
tracedir = self.tmpdir.join("tracedir")
|
||||
config = py.test.config._reparse([self.tmpdir,
|
||||
'--tracedir=%s' % tracedir])
|
||||
assert config.gettracedir() == tracedir
|
||||
|
||||
trace = config.maketrace("trace1.log", flush=True)
|
||||
trace = config.maketrace("trace1.log") # flush=True by default
|
||||
trace("hello", "world")
|
||||
class A: pass
|
||||
trace(A())
|
||||
|
|
Loading…
Reference in New Issue