summaryrefslogtreecommitdiff
path: root/lib/spack/external/_pytest/resultlog.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/external/_pytest/resultlog.py')
-rw-r--r--lib/spack/external/_pytest/resultlog.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/spack/external/_pytest/resultlog.py b/lib/spack/external/_pytest/resultlog.py
index fc00259834..9f9c2d1f65 100644
--- a/lib/spack/external/_pytest/resultlog.py
+++ b/lib/spack/external/_pytest/resultlog.py
@@ -1,15 +1,18 @@
""" log machine-parseable test session result information in a plain
text file.
"""
+from __future__ import absolute_import, division, print_function
import py
import os
+
def pytest_addoption(parser):
group = parser.getgroup("terminal reporting", "resultlog plugin options")
group.addoption('--resultlog', '--result-log', action="store",
- metavar="path", default=None,
- help="DEPRECATED path for machine-readable result log.")
+ metavar="path", default=None,
+ help="DEPRECATED path for machine-readable result log.")
+
def pytest_configure(config):
resultlog = config.option.resultlog
@@ -18,13 +21,14 @@ def pytest_configure(config):
dirname = os.path.dirname(os.path.abspath(resultlog))
if not os.path.isdir(dirname):
os.makedirs(dirname)
- logfile = open(resultlog, 'w', 1) # line buffered
+ logfile = open(resultlog, 'w', 1) # line buffered
config._resultlog = ResultLog(config, logfile)
config.pluginmanager.register(config._resultlog)
from _pytest.deprecated import RESULT_LOG
config.warn('C1', RESULT_LOG)
+
def pytest_unconfigure(config):
resultlog = getattr(config, '_resultlog', None)
if resultlog:
@@ -32,6 +36,7 @@ def pytest_unconfigure(config):
del config._resultlog
config.pluginmanager.unregister(resultlog)
+
def generic_path(item):
chain = item.listchain()
gpath = [chain[0].name]
@@ -55,15 +60,16 @@ def generic_path(item):
fspath = newfspath
return ''.join(gpath)
+
class ResultLog(object):
def __init__(self, config, logfile):
self.config = config
- self.logfile = logfile # preferably line buffered
+ self.logfile = logfile # preferably line buffered
def write_log_entry(self, testpath, lettercode, longrepr):
- py.builtin.print_("%s %s" % (lettercode, testpath), file=self.logfile)
+ print("%s %s" % (lettercode, testpath), file=self.logfile)
for line in longrepr.splitlines():
- py.builtin.print_(" %s" % line, file=self.logfile)
+ print(" %s" % line, file=self.logfile)
def log_outcome(self, report, lettercode, longrepr):
testpath = getattr(report, 'nodeid', None)