Automatically create directory for results
This commit is contained in:
parent
ca44e88e54
commit
1db5c95414
|
@ -203,6 +203,9 @@ class LogXML(object):
|
||||||
self.suite_start_time = time.time()
|
self.suite_start_time = time.time()
|
||||||
|
|
||||||
def pytest_sessionfinish(self):
|
def pytest_sessionfinish(self):
|
||||||
|
dirname = os.path.dirname(os.path.abspath(self.logfile))
|
||||||
|
if not os.path.exists(dirname):
|
||||||
|
os.makedirs(dirname)
|
||||||
logfile = open(self.logfile, 'w', encoding='utf-8')
|
logfile = open(self.logfile, 'w', encoding='utf-8')
|
||||||
suite_stop_time = time.time()
|
suite_stop_time = time.time()
|
||||||
suite_time_delta = suite_stop_time - self.suite_start_time
|
suite_time_delta = suite_stop_time - self.suite_start_time
|
||||||
|
|
|
@ -3,6 +3,7 @@ text file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
import os
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
group = parser.getgroup("terminal reporting", "resultlog plugin options")
|
group = parser.getgroup("terminal reporting", "resultlog plugin options")
|
||||||
|
@ -14,6 +15,9 @@ def pytest_configure(config):
|
||||||
resultlog = config.option.resultlog
|
resultlog = config.option.resultlog
|
||||||
# prevent opening resultlog on slave nodes (xdist)
|
# prevent opening resultlog on slave nodes (xdist)
|
||||||
if resultlog and not hasattr(config, 'slaveinput'):
|
if resultlog and not hasattr(config, 'slaveinput'):
|
||||||
|
dirname = os.path.dirname(os.path.abspath(resultlog))
|
||||||
|
if not os.path.exists(dirname):
|
||||||
|
os.makedirs(dirname)
|
||||||
logfile = open(resultlog, 'w', 1) # line buffered
|
logfile = open(resultlog, 'w', 1) # line buffered
|
||||||
config._resultlog = ResultLog(config, logfile)
|
config._resultlog = ResultLog(config, logfile)
|
||||||
config.pluginmanager.register(config._resultlog)
|
config.pluginmanager.register(config._resultlog)
|
||||||
|
|
Loading…
Reference in New Issue