[pypy-svn] pypy default: use actually released pytest-2.0.3 / py-1.4.3 versions
hpk42
commits-noreply at bitbucket.org
Thu Apr 28 17:41:28 CEST 2011
Author: holger krekel <holger at merlinux.eu>
Branch:
Changeset: r43725:e5594dda5978
Date: 2011-04-28 17:36 +0200
http://bitbucket.org/pypy/pypy/changeset/e5594dda5978/
Log: use actually released pytest-2.0.3 / py-1.4.3 versions (minor fixes
compared to the versions pypy already used)
diff --git a/_pytest/assertion.py b/_pytest/assertion.py
--- a/_pytest/assertion.py
+++ b/_pytest/assertion.py
@@ -16,7 +16,8 @@
# py._code._assertionnew to detect this plugin was loaded and in
# turn call the hooks defined here as part of the
# DebugInterpreter.
- config._monkeypatch = m = monkeypatch()
+ m = monkeypatch()
+ config._cleanup.append(m.undo)
warn_about_missing_assertion()
if not config.getvalue("noassert") and not config.getvalue("nomagic"):
def callbinrepr(op, left, right):
@@ -29,9 +30,6 @@
'AssertionError', py.code._AssertionError)
m.setattr(py.code, '_reprcompare', callbinrepr)
-def pytest_unconfigure(config):
- config._monkeypatch.undo()
-
def warn_about_missing_assertion():
try:
assert False
diff --git a/_pytest/__init__.py b/_pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
#
-__version__ = '2.0.3.dev3'
+__version__ = '2.0.3'
diff --git a/_pytest/main.py b/_pytest/main.py
--- a/_pytest/main.py
+++ b/_pytest/main.py
@@ -71,7 +71,7 @@
session.exitstatus = EXIT_INTERRUPTED
except:
excinfo = py.code.ExceptionInfo()
- config.pluginmanager.notify_exception(excinfo)
+ config.pluginmanager.notify_exception(excinfo, config.option)
session.exitstatus = EXIT_INTERNALERROR
if excinfo.errisinstance(SystemExit):
sys.stderr.write("mainloop: caught Spurious SystemExit!\n")
diff --git a/py/__init__.py b/py/__init__.py
--- a/py/__init__.py
+++ b/py/__init__.py
@@ -8,7 +8,7 @@
(c) Holger Krekel and others, 2004-2010
"""
-__version__ = '1.4.3.dev0'
+__version__ = '1.4.3'
from py import _apipkg
diff --git a/_pytest/core.py b/_pytest/core.py
--- a/_pytest/core.py
+++ b/_pytest/core.py
@@ -265,8 +265,15 @@
config.hook.pytest_unconfigure(config=config)
config.pluginmanager.unregister(self)
- def notify_exception(self, excinfo):
- excrepr = excinfo.getrepr(funcargs=True, showlocals=True)
+ def notify_exception(self, excinfo, option=None):
+ if option and option.fulltrace:
+ style = "long"
+ else:
+ style = "native"
+ excrepr = excinfo.getrepr(funcargs=True,
+ showlocals=getattr(option, 'showlocals', False),
+ style=style,
+ )
res = self.hook.pytest_internalerror(excrepr=excrepr)
if not py.builtin.any(res):
for line in str(excrepr).split("\n"):
diff --git a/_pytest/tmpdir.py b/_pytest/tmpdir.py
--- a/_pytest/tmpdir.py
+++ b/_pytest/tmpdir.py
@@ -48,15 +48,12 @@
self.trace("finish")
def pytest_configure(config):
- config._mp = mp = monkeypatch()
+ mp = monkeypatch()
t = TempdirHandler(config)
+ config._cleanup.extend([mp.undo, t.finish])
mp.setattr(config, '_tmpdirhandler', t, raising=False)
mp.setattr(pytest, 'ensuretemp', t.ensuretemp, raising=False)
-def pytest_unconfigure(config):
- config._tmpdirhandler.finish()
- config._mp.undo()
-
def pytest_funcarg__tmpdir(request):
"""return a temporary directory path object
which is unique to each test function invocation,
diff --git a/py/_io/terminalwriter.py b/py/_io/terminalwriter.py
--- a/py/_io/terminalwriter.py
+++ b/py/_io/terminalwriter.py
@@ -84,7 +84,8 @@
while len(text) > 32768:
file.write(text[:32768])
text = text[32768:]
- file.write(text)
+ if text:
+ file.write(text)
SetConsoleTextAttribute(handle, oldcolors)
else:
file.write(text)
diff --git a/_pytest/resultlog.py b/_pytest/resultlog.py
--- a/_pytest/resultlog.py
+++ b/_pytest/resultlog.py
@@ -74,7 +74,7 @@
elif report.failed:
longrepr = str(report.longrepr)
elif report.skipped:
- longrepr = str(report.longrepr)
+ longrepr = str(report.longrepr[2])
self.log_outcome(report, code, longrepr)
def pytest_collectreport(self, report):
diff --git a/_pytest/pytester.py b/_pytest/pytester.py
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -236,13 +236,14 @@
def _makefile(self, ext, args, kwargs):
items = list(kwargs.items())
if args:
- source = "\n".join(map(str, args)) + "\n"
+ source = py.builtin._totext("\n").join(
+ map(py.builtin._totext, args)) + py.builtin._totext("\n")
basename = self.request.function.__name__
items.insert(0, (basename, source))
ret = None
for name, value in items:
p = self.tmpdir.join(name).new(ext=ext)
- source = str(py.code.Source(value)).lstrip()
+ source = py.builtin._totext(py.code.Source(value)).lstrip()
p.write(source.encode("utf-8"), "wb")
if ret is None:
ret = p
diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -5,8 +5,42 @@
import py
import os
+import re
+import sys
import time
+
+# Python 2.X and 3.X compatibility
+try:
+ unichr(65)
+except NameError:
+ unichr = chr
+try:
+ unicode('A')
+except NameError:
+ unicode = str
+try:
+ long(1)
+except NameError:
+ long = int
+
+
+# We need to get the subset of the invalid unicode ranges according to
+# XML 1.0 which are valid in this python build. Hence we calculate
+# this dynamically instead of hardcoding it. The spec range of valid
+# chars is: Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
+# | [#x10000-#x10FFFF]
+_illegal_unichrs = [(0x00, 0x08), (0x0B, 0x0C), (0x0E, 0x19),
+ (0xD800, 0xDFFF), (0xFDD0, 0xFFFF)]
+_illegal_ranges = [unicode("%s-%s") % (unichr(low), unichr(high))
+ for (low, high) in _illegal_unichrs
+ if low < sys.maxunicode]
+illegal_xml_re = re.compile(unicode('[%s]') %
+ unicode('').join(_illegal_ranges))
+del _illegal_unichrs
+del _illegal_ranges
+
+
def pytest_addoption(parser):
group = parser.getgroup("terminal reporting")
group.addoption('--junitxml', action="store", dest="xmlpath",
@@ -28,6 +62,7 @@
del config._xml
config.pluginmanager.unregister(xml)
+
class LogXML(object):
def __init__(self, logfile, prefix):
self.logfile = logfile
@@ -55,7 +90,14 @@
self.test_logs.append("</testcase>")
def appendlog(self, fmt, *args):
- args = tuple([py.xml.escape(arg) for arg in args])
+ def repl(matchobj):
+ i = ord(matchobj.group())
+ if i <= 0xFF:
+ return unicode('#x%02X') % i
+ else:
+ return unicode('#x%04X') % i
+ args = tuple([illegal_xml_re.sub(repl, py.xml.escape(arg))
+ for arg in args])
self.test_logs.append(fmt % args)
def append_pass(self, report):
diff --git a/_pytest/config.py b/_pytest/config.py
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -12,6 +12,10 @@
config.trace.root.setwriter(sys.stderr.write)
return config
+def pytest_unconfigure(config):
+ for func in config._cleanup:
+ func()
+
class Parser:
""" Parser for command line arguments. """
@@ -251,7 +255,8 @@
self._conftest = Conftest(onimport=self._onimportconftest)
self.hook = self.pluginmanager.hook
self._inicache = {}
-
+ self._cleanup = []
+
@classmethod
def fromdictargs(cls, option_dict, args):
""" constructor useable for subprocesses. """
More information about the Pypy-commit
mailing list