[svn r57591] flush true by default

--HG--
branch : trunk
This commit is contained in:
hpk 2008-08-22 19:07:04 +02:00
parent 0dbe04abcb
commit a6f1e3d82f
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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())