Author: Ronny Pfannschmidt <[email protected]>
Branch: pytest
Changeset: r54264:f1fdc8c6ed6a
Date: 2012-04-09 11:38 +0200
http://bitbucket.org/pypy/pypy/changeset/f1fdc8c6ed6a/
Log: upgrade py and _pytest to current tip
diff --git a/_pytest/__init__.py b/_pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
#
-__version__ = '2.2.3'
+__version__ = '2.2.4.dev2'
diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py
--- a/_pytest/assertion/rewrite.py
+++ b/_pytest/assertion/rewrite.py
@@ -1,7 +1,6 @@
"""Rewrite assertion AST to produce nice error messages"""
import ast
-import collections
import errno
import itertools
import imp
diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -34,15 +34,21 @@
# 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
+_legal_chars = (0x09, 0x0A, 0x0d)
+_legal_ranges = (
+ (0x20, 0xD7FF),
+ (0xE000, 0xFFFD),
+ (0x10000, 0x10FFFF),
+)
+_legal_xml_re = [unicode("%s-%s") % (unichr(low), unichr(high))
+ for (low, high) in _legal_ranges
if low < sys.maxunicode]
-illegal_xml_re = re.compile(unicode('[%s]') %
- unicode('').join(_illegal_ranges))
-del _illegal_unichrs
-del _illegal_ranges
+_legal_xml_re = [unichr(x) for x in _legal_chars] + _legal_xml_re
+illegal_xml_re = re.compile(unicode('[^%s]') %
+ unicode('').join(_legal_xml_re))
+del _legal_chars
+del _legal_ranges
+del _legal_xml_re
def bin_xml_escape(arg):
def repl(matchobj):
diff --git a/_pytest/skipping.py b/_pytest/skipping.py
--- a/_pytest/skipping.py
+++ b/_pytest/skipping.py
@@ -132,6 +132,14 @@
def pytest_runtest_makereport(__multicall__, item, call):
if not isinstance(item, pytest.Function):
return
+ # unitttest special case, see setting of _unexpectedsuccess
+ if hasattr(item, '_unexpectedsuccess'):
+ rep = __multicall__.execute()
+ if rep.when == "call":
+ # we need to translate into how py.test encodes xpass
+ rep.keywords['xfail'] = "reason: " + item._unexpectedsuccess
+ rep.outcome = "failed"
+ return rep
if not (call.excinfo and
call.excinfo.errisinstance(py.test.xfail.Exception)):
evalxfail = getattr(item, '_evalxfail', None)
diff --git a/_pytest/unittest.py b/_pytest/unittest.py
--- a/_pytest/unittest.py
+++ b/_pytest/unittest.py
@@ -91,22 +91,28 @@
self._addexcinfo(rawexcinfo)
def addFailure(self, testcase, rawexcinfo):
self._addexcinfo(rawexcinfo)
+
def addSkip(self, testcase, reason):
try:
pytest.skip(reason)
except pytest.skip.Exception:
self._addexcinfo(sys.exc_info())
- def addExpectedFailure(self, testcase, rawexcinfo, reason):
+
+ def addExpectedFailure(self, testcase, rawexcinfo, reason=""):
try:
pytest.xfail(str(reason))
except pytest.xfail.Exception:
self._addexcinfo(sys.exc_info())
- def addUnexpectedSuccess(self, testcase, reason):
- pass
+
+ def addUnexpectedSuccess(self, testcase, reason=""):
+ self._unexpectedsuccess = reason
+
def addSuccess(self, testcase):
pass
+
def stopTest(self, testcase):
pass
+
def runtest(self):
self._testcase(result=self)
diff --git a/py/_builtin.py b/py/_builtin.py
--- a/py/_builtin.py
+++ b/py/_builtin.py
@@ -113,9 +113,12 @@
# some backward compatibility helpers
_basestring = str
- def _totext(obj, encoding=None):
+ def _totext(obj, encoding=None, errors=None):
if isinstance(obj, bytes):
- obj = obj.decode(encoding)
+ if errors is None:
+ obj = obj.decode(encoding)
+ else:
+ obj = obj.decode(encoding, errors)
elif not isinstance(obj, str):
obj = str(obj)
return obj
diff --git a/py/_error.py b/py/_error.py
--- a/py/_error.py
+++ b/py/_error.py
@@ -23,6 +23,7 @@
2: errno.ENOENT,
3: errno.ENOENT,
17: errno.EEXIST,
+ 13: errno.EBUSY, # empty cd drive, but ENOMEDIUM seems unavailiable
22: errno.ENOTDIR,
267: errno.ENOTDIR,
5: errno.EACCES, # anything better?
diff --git a/py/_io/capture.py b/py/_io/capture.py
--- a/py/_io/capture.py
+++ b/py/_io/capture.py
@@ -12,7 +12,7 @@
class TextIO(StringIO):
def write(self, data):
if not isinstance(data, unicode):
- data = unicode(data, getattr(self, '_encoding', 'UTF-8'))
+ data = unicode(data, getattr(self, '_encoding', 'UTF-8'),
'replace')
StringIO.write(self, data)
else:
TextIO = StringIO
@@ -260,7 +260,7 @@
res = f.read()
enc = getattr(f, 'encoding', None)
if enc:
- res = py.builtin._totext(res, enc)
+ res = py.builtin._totext(res, enc, 'replace')
f.truncate(0)
f.seek(0)
l.append(res)
diff --git a/py/_path/common.py b/py/_path/common.py
--- a/py/_path/common.py
+++ b/py/_path/common.py
@@ -64,7 +64,10 @@
else:
if bool(value) ^ bool(meth()) ^ invert:
return False
- except (py.error.ENOENT, py.error.ENOTDIR):
+ except (py.error.ENOENT, py.error.ENOTDIR, py.error.EBUSY):
+ # EBUSY feels not entirely correct,
+ # but its kind of necessary since ENOMEDIUM
+ # is not accessible in python
for name in self._depend_on_existence:
if name in kw:
if kw.get(name):
diff --git a/py/_xmlgen.py b/py/_xmlgen.py
--- a/py/_xmlgen.py
+++ b/py/_xmlgen.py
@@ -52,7 +52,7 @@
def unicode(self, indent=2):
l = []
SimpleUnicodeVisitor(l.append, indent).visit(self)
- return "".join(l)
+ return u("").join(l)
def __repr__(self):
name = self.__class__.__name__
@@ -122,11 +122,13 @@
if visitmethod is not None:
break
else:
- visitmethod = self.object
+ visitmethod = self.__object
self.cache[cls] = visitmethod
visitmethod(node)
- def object(self, obj):
+ # the default fallback handler is marked private
+ # to avoid clashes with the tag name object
+ def __object(self, obj):
#self.write(obj)
self.write(escape(unicode(obj)))
@@ -182,7 +184,11 @@
value = getattr(attrs, name)
if name.endswith('_'):
name = name[:-1]
- return ' %s="%s"' % (name, escape(unicode(value)))
+ if isinstance(value, raw):
+ insert = value.uniobj
+ else:
+ insert = escape(unicode(value))
+ return ' %s="%s"' % (name, insert)
def getstyle(self, tag):
""" return attribute list suitable for styling. """
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit