diff options
author | 2016-11-15 01:52:53 +0000 | |
---|---|---|
committer | 2016-11-15 01:52:53 +0000 | |
commit | 2645c616eb22dfe97df2e3062f3a70db47a09fdb (patch) | |
tree | dadfbe0a626d346216ab4e9e6fe1d44f70d35d4f /_pytest | |
parent | copy upstream pytest-2.9.2 and py-1.4.29 (diff) | |
parent | Move 2 scripts used only by PyPy to pypy/tool/ (diff) | |
download | pypy-2645c616eb22dfe97df2e3062f3a70db47a09fdb.tar.gz pypy-2645c616eb22dfe97df2e3062f3a70db47a09fdb.tar.bz2 pypy-2645c616eb22dfe97df2e3062f3a70db47a09fdb.zip |
hg merge default
Diffstat (limited to '_pytest')
-rw-r--r-- | _pytest/README-BEFORE-UPDATING | 17 | ||||
-rw-r--r-- | _pytest/resultlog.py | 21 |
2 files changed, 34 insertions, 4 deletions
diff --git a/_pytest/README-BEFORE-UPDATING b/_pytest/README-BEFORE-UPDATING new file mode 100644 index 0000000000..10b95ee2a6 --- /dev/null +++ b/_pytest/README-BEFORE-UPDATING @@ -0,0 +1,17 @@ +This is PyPy's code of the pytest lib. We don't expect to upgrade it +very often, but once we do: + + WARNING! + + WE HAVE MADE A FEW TWEAKS HERE! + +Please be sure that you don't just copy the newer version from +upstream without checking the few changes that we did. This +can be done like this: + + cd <this directory> + hg log . -v | less + +then search for all " _pytest/" in that list to know which are the +relevant checkins. (Look for the checkins that only edit one +or two files in this directory.) diff --git a/_pytest/resultlog.py b/_pytest/resultlog.py index 3670f0214c..ac7a3db3c1 100644 --- a/_pytest/resultlog.py +++ b/_pytest/resultlog.py @@ -57,16 +57,24 @@ class ResultLog(object): self.config = config self.logfile = logfile # preferably line buffered - def write_log_entry(self, testpath, lettercode, longrepr): - py.builtin.print_("%s %s" % (lettercode, testpath), file=self.logfile) + def write_log_entry(self, testpath, lettercode, longrepr, sections=None): + _safeprint("%s %s" % (lettercode, testpath), file=self.logfile) for line in longrepr.splitlines(): - py.builtin.print_(" %s" % line, file=self.logfile) + _safeprint(" %s" % line, file=self.logfile) + if sections is not None and ( + lettercode in ('E', 'F')): # to limit the size of logs + for title, content in sections: + _safeprint(" ---------- %s ----------" % (title,), + file=self.logfile) + for line in content.splitlines(): + _safeprint(" %s" % line, file=self.logfile) def log_outcome(self, report, lettercode, longrepr): testpath = getattr(report, 'nodeid', None) if testpath is None: testpath = report.fspath - self.write_log_entry(testpath, lettercode, longrepr) + self.write_log_entry(testpath, lettercode, longrepr, + getattr(report, 'sections', None)) def pytest_runtest_logreport(self, report): if report.when != "call" and report.passed: @@ -102,3 +110,8 @@ class ResultLog(object): if path is None: path = "cwd:%s" % py.path.local() self.write_log_entry(path, '!', str(excrepr)) + +def _safeprint(s, file): + if isinstance(s, unicode): + s = s.encode('utf-8') + py.builtin.print_(s, file=file) |