From bf42c88e482f1a0d2bcf7e90b34aac5b2304ac01 Mon Sep 17 00:00:00 2001 From: hpk Date: Thu, 21 Aug 2008 19:25:48 +0200 Subject: [PATCH] [svn r57564] adding an option for setting a tracedirectory so that components can write log files, depending on what they get from config.gettracedir() --HG-- branch : trunk --- py/test/config.py | 6 ++++++ py/test/defaultconftest.py | 3 +++ py/test/testing/test_config.py | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/py/test/config.py b/py/test/config.py index f9c8c8071..6488bde30 100644 --- a/py/test/config.py +++ b/py/test/config.py @@ -220,6 +220,12 @@ class Config(object): else: raise ValueError("unknown io capturing: " + iocapture) + + def gettracedir(self): + """ return a tracedirectory or None, depending on --tracedir. """ + if self.option.tracedir is not None: + return py.path.local(self.option.tracedir) + # this is the one per-process instance of py.test configuration config_per_process = Config() diff --git a/py/test/defaultconftest.py b/py/test/defaultconftest.py index cf5b01a04..1d34e1553 100644 --- a/py/test/defaultconftest.py +++ b/py/test/defaultconftest.py @@ -55,6 +55,9 @@ def adddefaultoptions(config): Option('', '--eventlog', action="store", dest="eventlog", default=None, help="write reporting events to given file."), + Option('', '--tracedir', + action="store", dest="tracedir", default=None, + help="write tracing information to the given directory."), Option('', '--tb', action="store", dest="tbstyle", default='long', type="choice", choices=['long', 'short', 'no'], diff --git a/py/test/testing/test_config.py b/py/test/testing/test_config.py index abbab24f4..2ca255db0 100644 --- a/py/test/testing/test_config.py +++ b/py/test/testing/test_config.py @@ -201,6 +201,14 @@ class TestSessionAndOptions: s = eventlog.read() assert s.find("TestrunStart") != -1 + def test_tracedir(self): + tracedir = self.tmpdir.mkdir("tracedir") + config = py.test.config._reparse([self.tmpdir, + '--tracedir=%s' % tracedir]) + assert config.gettracedir() == tracedir + config = py.test.config._reparse([self.tmpdir]) + assert config.gettracedir() is None + def test_implied_dsession(self): for x in 'startserver runbrowser rest'.split(): config = py.test.config._reparse([self.tmpdir, '--dist', '--%s' % x])