Hello community, here is the log from the commit of package python3-py for openSUSE:Factory checked in at 2014-04-23 20:37:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-py (Old) and /work/SRC/openSUSE:Factory/.python3-py.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-py" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-py/python3-py.changes 2014-01-07 16:26:16.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python3-py.new/python3-py.changes 2014-04-23 20:37:21.000000000 +0200 @@ -1,0 +2,12 @@ +Wed Apr 23 13:47:10 UTC 2014 - [email protected] + +- Update to version 1.4.20: + + ignore unicode decode errors in xmlescape. Thanks Anatoly Bubenkoff. + + on python2 modify traceback.format_exception_only to match python3 + behaviour, namely trying to print unicode for Exception instances + + use a safer way for serializing exception reports (helps to fix + pytest issue413) +- Drop %check section, we never ran tests. That would need python-pytest + and introduce a cycle + +------------------------------------------------------------------- Old: ---- py-1.4.19.tar.gz New: ---- py-1.4.20.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-py.spec ++++++ --- /var/tmp/diff_new_pack.ytsVra/_old 2014-04-23 20:37:22.000000000 +0200 +++ /var/tmp/diff_new_pack.ytsVra/_new 2014-04-23 20:37:22.000000000 +0200 @@ -17,7 +17,7 @@ Name: python3-py -Version: 1.4.19 +Version: 1.4.20 Release: 0 Summary: Library with cross-python path, ini-parsing, io, code, log facilities License: MIT @@ -53,9 +53,6 @@ %install python3 setup.py install --prefix=%{_prefix} --root=%{buildroot} -%check -python3 setup.py test - %files %defattr(-,root,root,-) %doc LICENSE README.txt doc/_build/html ++++++ py-1.4.19.tar.gz -> py-1.4.20.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/CHANGELOG new/py-1.4.20/CHANGELOG --- old/py-1.4.19/CHANGELOG 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/CHANGELOG 2014-01-29 13:16:52.000000000 +0100 @@ -1,3 +1,14 @@ +1.4.20 +================================================== + +- ignore unicode decode errors in xmlescape. Thanks Anatoly Bubenkoff. + +- on python2 modify traceback.format_exception_only to match python3 + behaviour, namely trying to print unicode for Exception instances + +- use a safer way for serializing exception reports (helps to fix + pytest issue413) + Changes between 1.4.18 and 1.4.19 ================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/MANIFEST.in new/py-1.4.20/MANIFEST.in --- old/py-1.4.19/MANIFEST.in 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/MANIFEST.in 2014-01-29 13:16:52.000000000 +0100 @@ -1,7 +1,6 @@ include CHANGELOG include README.txt include setup.py -include distribute_setup.py include LICENSE include conftest.py include tox.ini diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/PKG-INFO new/py-1.4.20/PKG-INFO --- old/py-1.4.19/PKG-INFO 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/PKG-INFO 2014-01-29 13:16:53.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: py -Version: 1.4.19 +Version: 1.4.20 Summary: library with cross-python path, ini-parsing, io, code, log facilities Home-page: http://pylib.readthedocs.org/ Author: holger krekel, Ronny Pfannschmidt, Benjamin Peterson and others diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/doc/code.txt new/py-1.4.20/doc/code.txt --- old/py-1.4.19/doc/code.txt 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/doc/code.txt 2014-01-29 13:16:52.000000000 +0100 @@ -145,3 +145,6 @@ .. autoclass:: py.code.ExceptionInfo :members: +.. autoclass:: py.code.Traceback + :members: + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/py/__init__.py new/py-1.4.20/py/__init__.py --- old/py-1.4.19/py/__init__.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/py/__init__.py 2014-01-29 13:16:52.000000000 +0100 @@ -8,7 +8,7 @@ (c) Holger Krekel and others, 2004-2013 """ -__version__ = '1.4.19' +__version__ = '1.4.20' from py import _apipkg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/py/_code/_py2traceback.py new/py-1.4.20/py/_code/_py2traceback.py --- old/py-1.4.19/py/_code/_py2traceback.py 1970-01-01 01:00:00.000000000 +0100 +++ new/py-1.4.20/py/_code/_py2traceback.py 2014-01-29 13:16:52.000000000 +0100 @@ -0,0 +1,79 @@ +# copied from python-2.7.3's traceback.py +# CHANGES: +# - some_str is replaced, trying to create unicode strings +# +import types + +def format_exception_only(etype, value): + """Format the exception part of a traceback. + + The arguments are the exception type and value such as given by + sys.last_type and sys.last_value. The return value is a list of + strings, each ending in a newline. + + Normally, the list contains a single string; however, for + SyntaxError exceptions, it contains several lines that (when + printed) display detailed information about where the syntax + error occurred. + + The message indicating which exception occurred is always the last + string in the list. + + """ + + # An instance should not have a meaningful value parameter, but + # sometimes does, particularly for string exceptions, such as + # >>> raise string1, string2 # deprecated + # + # Clear these out first because issubtype(string1, SyntaxError) + # would throw another exception and mask the original problem. + if (isinstance(etype, BaseException) or + isinstance(etype, types.InstanceType) or + etype is None or type(etype) is str): + return [_format_final_exc_line(etype, value)] + + stype = etype.__name__ + + if not issubclass(etype, SyntaxError): + return [_format_final_exc_line(stype, value)] + + # It was a syntax error; show exactly where the problem was found. + lines = [] + try: + msg, (filename, lineno, offset, badline) = value.args + except Exception: + pass + else: + filename = filename or "<string>" + lines.append(' File "%s", line %d\n' % (filename, lineno)) + if badline is not None: + lines.append(' %s\n' % badline.strip()) + if offset is not None: + caretspace = badline.rstrip('\n')[:offset].lstrip() + # non-space whitespace (likes tabs) must be kept for alignment + caretspace = ((c.isspace() and c or ' ') for c in caretspace) + # only three spaces to account for offset1 == pos 0 + lines.append(' %s^\n' % ''.join(caretspace)) + value = msg + + lines.append(_format_final_exc_line(stype, value)) + return lines + +def _format_final_exc_line(etype, value): + """Return a list of a single line -- normal case for format_exception_only""" + valuestr = _some_str(value) + if value is None or not valuestr: + line = "%s\n" % etype + else: + line = "%s: %s\n" % (etype, valuestr) + return line + +def _some_str(value): + try: + return unicode(value) + except Exception: + try: + return str(value) + except Exception: + pass + return '<unprintable %s object>' % type(value).__name__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/py/_code/code.py new/py-1.4.20/py/_code/code.py --- old/py-1.4.19/py/_code/code.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/py/_code/code.py 2014-01-29 13:16:52.000000000 +0100 @@ -6,6 +6,11 @@ reprlib = py.builtin._tryimport('repr', 'reprlib') +if sys.version_info[0] >= 3: + from traceback import format_exception_only +else: + from py._code._py2traceback import format_exception_only + class Code(object): """ wrapper around Python code objects """ def __init__(self, rawcode): @@ -331,8 +336,6 @@ """ _striptext = '' def __init__(self, tup=None, exprinfo=None): - # NB. all attributes are private! Subclasses or other - # ExceptionInfo-like classes may have different attributes. if tup is None: tup = sys.exc_info() if exprinfo is None and isinstance(tup[1], AssertionError): @@ -342,9 +345,16 @@ if exprinfo and exprinfo.startswith('assert '): self._striptext = 'AssertionError: ' self._excinfo = tup - self.type, self.value, tb = tup + #: the exception class + self.type = tup[0] + #: the exception instance + self.value = tup[1] + #: the exception raw traceback + self.tb = tup[2] + #: the exception type name self.typename = self.type.__name__ - self.traceback = py.code.Traceback(tb) + #: the exception traceback (py.code.Traceback instance) + self.traceback = py.code.Traceback(self.tb) def __repr__(self): return "<ExceptionInfo %s tblen=%d>" % (self.typename, len(self.traceback)) @@ -357,7 +367,7 @@ the exception representation is returned (so 'AssertionError: ' is removed from the beginning) """ - lines = self._format_exception_only(self.type, self.value) + lines = format_exception_only(self.type, self.value) text = ''.join(lines) text = text.rstrip() if tryshort: @@ -365,17 +375,6 @@ text = text[len(self._striptext):] return text - def _format_exception_only(self, etype, value): - """Format the exception part of a traceback - - Since traceback.format_exception_only() destroys unicode on - python 2 we handle plain AsssertionErrors separately here. - """ - if isinstance(value, AssertionError) and hasattr(value, 'msg'): - return ['AssertionError: ' + value.msg] - else: - return py.std.traceback.format_exception_only(etype, value) - def errisinstance(self, exc): """ return True if the exception is an instance of exc """ return isinstance(self.value, exc) @@ -594,22 +593,16 @@ return s def __unicode__(self): - l = [] - tw = py.io.TerminalWriter(l.append) + # FYI this is called from pytest-xdist's serialization of exception + # information. + io = py.io.TextIO() + tw = py.io.TerminalWriter(file=io) self.toterminal(tw) - l = map(unicode_or_repr, l) - return "".join(l).strip() + return io.getvalue().strip() def __repr__(self): return "<%s instance at %0x>" %(self.__class__, id(self)) -def unicode_or_repr(obj): - try: - return py.builtin._totext(obj) - except KeyboardInterrupt: - raise - except Exception: - return "<print-error: %r>" % py.io.saferepr(obj) class ReprExceptionInfo(TerminalRepr): def __init__(self, reprtraceback, reprcrash): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/py/_io/capture.py new/py-1.4.20/py/_io/capture.py --- old/py-1.4.19/py/_io/capture.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/py/_io/capture.py 2014-01-29 13:16:52.000000000 +0100 @@ -183,7 +183,14 @@ """ def __init__(self, out=True, err=True, mixed=False, in_=True, patchsys=True, now=True): - self._options = locals() + self._options = { + "out": out, + "err": err, + "mixed": mixed, + "in_": in_, + "patchsys": patchsys, + "now": now, + } self._save() if now: self.startall() @@ -251,20 +258,26 @@ def readouterr(self): """ return snapshot value of stdout/stderr capturings. """ - l = [] - for name in ('out', 'err'): - res = "" - if hasattr(self, name): - f = getattr(self, name).tmpfile - f.seek(0) - res = f.read() - enc = getattr(f, 'encoding', None) - if enc: - res = py.builtin._totext(res, enc, 'replace') - f.truncate(0) - f.seek(0) - l.append(res) - return l + if hasattr(self, "out"): + out = self._readsnapshot(self.out.tmpfile) + else: + out = "" + if hasattr(self, "err"): + err = self._readsnapshot(self.err.tmpfile) + else: + err = "" + return [out, err] + + def _readsnapshot(self, f): + f.seek(0) + res = f.read() + enc = getattr(f, "encoding", None) + if enc: + res = py.builtin._totext(res, enc, "replace") + f.truncate(0) + f.seek(0) + return res + class StdCapture(Capture): """ This class allows to capture writes to sys.stdout|stderr "in-memory" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/py/_xmlgen.py new/py-1.4.20/py/_xmlgen.py --- old/py-1.4.19/py/_xmlgen.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/py/_xmlgen.py 2014-01-29 13:16:52.000000000 +0100 @@ -9,7 +9,7 @@ if sys.version_info >= (3,0): def u(s): return s - def unicode(x): + def unicode(x, errors=None): if hasattr(x, '__unicode__'): return x.__unicode__() return str(x) @@ -244,7 +244,10 @@ def __call__(self, ustring): """ xml-escape the given unicode string. """ - ustring = unicode(ustring) + try: + ustring = unicode(ustring) + except UnicodeDecodeError: + ustring = unicode(ustring, 'utf-8', errors='replace') return self.charef_rex.sub(self._replacer, ustring) escape = _escape() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/py.egg-info/PKG-INFO new/py-1.4.20/py.egg-info/PKG-INFO --- old/py-1.4.19/py.egg-info/PKG-INFO 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/py.egg-info/PKG-INFO 2014-01-29 13:16:53.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: py -Version: 1.4.19 +Version: 1.4.20 Summary: library with cross-python path, ini-parsing, io, code, log facilities Home-page: http://pylib.readthedocs.org/ Author: holger krekel, Ronny Pfannschmidt, Benjamin Peterson and others diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/py.egg-info/SOURCES.txt new/py-1.4.20/py.egg-info/SOURCES.txt --- old/py-1.4.19/py.egg-info/SOURCES.txt 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/py.egg-info/SOURCES.txt 2014-01-29 13:16:53.000000000 +0100 @@ -59,6 +59,7 @@ py/_code/__init__.py py/_code/_assertionnew.py py/_code/_assertionold.py +py/_code/_py2traceback.py py/_code/assertion.py py/_code/code.py py/_code/source.py @@ -86,7 +87,6 @@ testing/code/test_excinfo.py testing/code/test_source.py testing/io_/__init__.py -testing/io_/test_capture.py testing/io_/test_saferepr.py testing/io_/test_terminalwriter.py testing/log/__init__.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/setup.py new/py-1.4.20/setup.py --- old/py-1.4.19/setup.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/setup.py 2014-01-29 13:16:52.000000000 +0100 @@ -7,7 +7,7 @@ name='py', description='library with cross-python path, ini-parsing, io, code, log facilities', long_description = open('README.txt').read(), - version='1.4.19', + version='1.4.20', url='http://pylib.readthedocs.org/', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/testing/code/test_code.py new/py-1.4.20/testing/code/test_code.py --- old/py-1.4.19/testing/code/test_code.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/testing/code/test_code.py 2014-01-29 13:16:52.000000000 +0100 @@ -89,23 +89,6 @@ if sys.version_info[0] < 3: u = unicode(excinfo) -def test_unicode_or_repr(): - from py._code.code import unicode_or_repr - assert unicode_or_repr('hello') == "hello" - if sys.version_info[0] < 3: - s = unicode_or_repr('\xf6\xc4\x85') - else: - s = eval("unicode_or_repr(b'\\f6\\xc4\\x85')") - assert 'print-error' in s - assert 'c4' in s - class A: - def __repr__(self): - raise ValueError() - s = unicode_or_repr(A()) - assert 'print-error' in s - assert 'ValueError' in s - - def test_code_getargs(): def f1(x): pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/testing/code/test_excinfo.py new/py-1.4.20/testing/code/test_excinfo.py --- old/py-1.4.19/testing/code/test_excinfo.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/testing/code/test_excinfo.py 2014-01-29 13:16:52.000000000 +0100 @@ -727,6 +727,14 @@ assert isinstance(repr, ReprExceptionInfo) assert repr.reprtraceback.style == style + def test_reprexcinfo_unicode(self): + from py._code.code import TerminalRepr + class MyRepr(TerminalRepr): + def toterminal(self, tw): + tw.line(py.builtin._totext("я", "utf-8")) + x = py.builtin._totext(MyRepr()) + assert x == py.builtin._totext("я", "utf-8") + def test_toterminal_long(self, importasmod): mod = importasmod(""" def g(x): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/testing/io_/test_capture.py new/py-1.4.20/testing/io_/test_capture.py --- old/py-1.4.19/testing/io_/test_capture.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/testing/io_/test_capture.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,501 +0,0 @@ -from __future__ import with_statement - -import os, sys -import py - -needsdup = py.test.mark.skipif("not hasattr(os, 'dup')") - -from py.builtin import print_ - -if sys.version_info >= (3,0): - def tobytes(obj): - if isinstance(obj, str): - obj = obj.encode('UTF-8') - assert isinstance(obj, bytes) - return obj - def totext(obj): - if isinstance(obj, bytes): - obj = str(obj, 'UTF-8') - assert isinstance(obj, str) - return obj -else: - def tobytes(obj): - if isinstance(obj, unicode): - obj = obj.encode('UTF-8') - assert isinstance(obj, str) - return obj - def totext(obj): - if isinstance(obj, str): - obj = unicode(obj, 'UTF-8') - assert isinstance(obj, unicode) - return obj - -def oswritebytes(fd, obj): - os.write(fd, tobytes(obj)) - -class TestTextIO: - def test_text(self): - f = py.io.TextIO() - f.write("hello") - s = f.getvalue() - assert s == "hello" - f.close() - - def test_unicode_and_str_mixture(self): - f = py.io.TextIO() - if sys.version_info >= (3,0): - f.write("\u00f6") - py.test.raises(TypeError, "f.write(bytes('hello', 'UTF-8'))") - else: - f.write(unicode("\u00f6", 'UTF-8')) - f.write("hello") # bytes - s = f.getvalue() - f.close() - assert isinstance(s, unicode) - -def test_bytes_io(): - f = py.io.BytesIO() - f.write(tobytes("hello")) - py.test.raises(TypeError, "f.write(totext('hello'))") - s = f.getvalue() - assert s == tobytes("hello") - -def test_dontreadfrominput(): - from py._io.capture import DontReadFromInput - f = DontReadFromInput() - assert not f.isatty() - py.test.raises(IOError, f.read) - py.test.raises(IOError, f.readlines) - py.test.raises(IOError, iter, f) - py.test.raises(ValueError, f.fileno) - f.close() # just for completeness - -def pytest_funcarg__tmpfile(request): - testdir = request.getfuncargvalue("testdir") - f = testdir.makepyfile("").open('wb+') - request.addfinalizer(f.close) - return f - -@needsdup -def test_dupfile(tmpfile): - flist = [] - for i in range(5): - nf = py.io.dupfile(tmpfile, encoding="utf-8") - assert nf != tmpfile - assert nf.fileno() != tmpfile.fileno() - assert nf not in flist - print_(i, end="", file=nf) - flist.append(nf) - for i in range(5): - f = flist[i] - f.close() - tmpfile.seek(0) - s = tmpfile.read() - assert "01234" in repr(s) - tmpfile.close() - -def test_dupfile_no_mode(): - """ - dupfile should trap an AttributeError and return f if no mode is supplied. - """ - class SomeFileWrapper(object): - "An object with a fileno method but no mode attribute" - def fileno(self): - return 1 - tmpfile = SomeFileWrapper() - assert py.io.dupfile(tmpfile) is tmpfile - with py.test.raises(AttributeError): - py.io.dupfile(tmpfile, raising=True) - -def lsof_check(func): - pid = os.getpid() - try: - out = py.process.cmdexec("lsof -p %d" % pid) - except py.process.cmdexec.Error: - py.test.skip("could not run 'lsof'") - func() - out2 = py.process.cmdexec("lsof -p %d" % pid) - len1 = len([x for x in out.split("\n") if "REG" in x]) - len2 = len([x for x in out2.split("\n") if "REG" in x]) - assert len2 < len1 + 3, out2 - -class TestFDCapture: - pytestmark = needsdup - - def test_not_now(self, tmpfile): - fd = tmpfile.fileno() - cap = py.io.FDCapture(fd, now=False) - data = tobytes("hello") - os.write(fd, data) - f = cap.done() - s = f.read() - assert not s - cap = py.io.FDCapture(fd, now=False) - cap.start() - os.write(fd, data) - f = cap.done() - s = f.read() - assert s == "hello" - - def test_simple(self, tmpfile): - fd = tmpfile.fileno() - cap = py.io.FDCapture(fd) - data = tobytes("hello") - os.write(fd, data) - f = cap.done() - s = f.read() - assert s == "hello" - f.close() - - def test_simple_many(self, tmpfile): - for i in range(10): - self.test_simple(tmpfile) - - def test_simple_many_check_open_files(self, tmpfile): - lsof_check(lambda: self.test_simple_many(tmpfile)) - - def test_simple_fail_second_start(self, tmpfile): - fd = tmpfile.fileno() - cap = py.io.FDCapture(fd) - f = cap.done() - py.test.raises(ValueError, cap.start) - f.close() - - def test_stderr(self): - cap = py.io.FDCapture(2, patchsys=True) - print_("hello", file=sys.stderr) - f = cap.done() - s = f.read() - assert s == "hello\n" - - def test_stdin(self, tmpfile): - tmpfile.write(tobytes("3")) - tmpfile.seek(0) - cap = py.io.FDCapture(0, tmpfile=tmpfile) - # check with os.read() directly instead of raw_input(), because - # sys.stdin itself may be redirected (as py.test now does by default) - x = os.read(0, 100).strip() - f = cap.done() - assert x == tobytes("3") - - def test_writeorg(self, tmpfile): - data1, data2 = tobytes("foo"), tobytes("bar") - try: - cap = py.io.FDCapture(tmpfile.fileno()) - tmpfile.write(data1) - cap.writeorg(data2) - finally: - tmpfile.close() - f = cap.done() - scap = f.read() - assert scap == totext(data1) - stmp = open(tmpfile.name, 'rb').read() - assert stmp == data2 - - -class TestStdCapture: - def getcapture(self, **kw): - return py.io.StdCapture(**kw) - - def test_capturing_done_simple(self): - cap = self.getcapture() - sys.stdout.write("hello") - sys.stderr.write("world") - outfile, errfile = cap.done() - s = outfile.read() - assert s == "hello" - s = errfile.read() - assert s == "world" - - def test_capturing_reset_simple(self): - cap = self.getcapture() - print("hello world") - sys.stderr.write("hello error\n") - out, err = cap.reset() - assert out == "hello world\n" - assert err == "hello error\n" - - def test_capturing_readouterr(self): - cap = self.getcapture() - try: - print ("hello world") - sys.stderr.write("hello error\n") - out, err = cap.readouterr() - assert out == "hello world\n" - assert err == "hello error\n" - sys.stderr.write("error2") - finally: - out, err = cap.reset() - assert err == "error2" - - def test_capturing_readouterr_unicode(self): - cap = self.getcapture() - print ("hx\xc4\x85\xc4\x87") - out, err = cap.readouterr() - assert out == py.builtin._totext("hx\xc4\x85\xc4\x87\n", "utf8") - - @py.test.mark.skipif('sys.version_info >= (3,)', - reason='text output different for bytes on python3') - def test_capturing_readouterr_decode_error_handling(self): - cap = self.getcapture() - # triggered a internal error in pytest - print('\xa6') - out, err = cap.readouterr() - assert out == py.builtin._totext('\ufffd\n', 'unicode-escape') - - def test_capturing_mixed(self): - cap = self.getcapture(mixed=True) - sys.stdout.write("hello ") - sys.stderr.write("world") - sys.stdout.write(".") - out, err = cap.reset() - assert out.strip() == "hello world." - assert not err - - def test_reset_twice_error(self): - cap = self.getcapture() - print ("hello") - out, err = cap.reset() - py.test.raises(ValueError, cap.reset) - assert out == "hello\n" - assert not err - - def test_capturing_modify_sysouterr_in_between(self): - oldout = sys.stdout - olderr = sys.stderr - cap = self.getcapture() - sys.stdout.write("hello") - sys.stderr.write("world") - sys.stdout = py.io.TextIO() - sys.stderr = py.io.TextIO() - print ("not seen") - sys.stderr.write("not seen\n") - out, err = cap.reset() - assert out == "hello" - assert err == "world" - assert sys.stdout == oldout - assert sys.stderr == olderr - - def test_capturing_error_recursive(self): - cap1 = self.getcapture() - print ("cap1") - cap2 = self.getcapture() - print ("cap2") - out2, err2 = cap2.reset() - out1, err1 = cap1.reset() - assert out1 == "cap1\n" - assert out2 == "cap2\n" - - def test_just_out_capture(self): - cap = self.getcapture(out=True, err=False) - sys.stdout.write("hello") - sys.stderr.write("world") - out, err = cap.reset() - assert out == "hello" - assert not err - - def test_just_err_capture(self): - cap = self.getcapture(out=False, err=True) - sys.stdout.write("hello") - sys.stderr.write("world") - out, err = cap.reset() - assert err == "world" - assert not out - - def test_stdin_restored(self): - old = sys.stdin - cap = self.getcapture(in_=True) - newstdin = sys.stdin - out, err = cap.reset() - assert newstdin != sys.stdin - assert sys.stdin is old - - def test_stdin_nulled_by_default(self): - print ("XXX this test may well hang instead of crashing") - print ("XXX which indicates an error in the underlying capturing") - print ("XXX mechanisms") - cap = self.getcapture() - py.test.raises(IOError, "sys.stdin.read()") - out, err = cap.reset() - - def test_suspend_resume(self): - cap = self.getcapture(out=True, err=False, in_=False) - try: - print ("hello") - sys.stderr.write("error\n") - out, err = cap.suspend() - assert out == "hello\n" - assert not err - print ("in between") - sys.stderr.write("in between\n") - cap.resume() - print ("after") - sys.stderr.write("error_after\n") - finally: - out, err = cap.reset() - assert out == "after\n" - assert not err - -class TestStdCaptureNotNow(TestStdCapture): - def getcapture(self, **kw): - kw['now'] = False - cap = py.io.StdCapture(**kw) - cap.startall() - return cap - -class TestStdCaptureFD(TestStdCapture): - pytestmark = needsdup - - def getcapture(self, **kw): - return py.io.StdCaptureFD(**kw) - - def test_intermingling(self): - cap = self.getcapture() - oswritebytes(1, "1") - sys.stdout.write(str(2)) - sys.stdout.flush() - oswritebytes(1, "3") - oswritebytes(2, "a") - sys.stderr.write("b") - sys.stderr.flush() - oswritebytes(2, "c") - out, err = cap.reset() - assert out == "123" - assert err == "abc" - - def test_callcapture(self): - def func(x, y): - print (x) - py.std.sys.stderr.write(str(y)) - return 42 - - res, out, err = py.io.StdCaptureFD.call(func, 3, y=4) - assert res == 42 - assert out.startswith("3") - assert err.startswith("4") - - def test_many(self, capfd): - def f(): - for i in range(10): - cap = py.io.StdCaptureFD() - cap.reset() - lsof_check(f) - -class TestStdCaptureFDNotNow(TestStdCaptureFD): - pytestmark = needsdup - - def getcapture(self, **kw): - kw['now'] = False - cap = py.io.StdCaptureFD(**kw) - cap.startall() - return cap - -@needsdup -def test_stdcapture_fd_tmpfile(tmpfile): - capfd = py.io.StdCaptureFD(out=tmpfile) - os.write(1, "hello".encode("ascii")) - os.write(2, "world".encode("ascii")) - outf, errf = capfd.done() - assert outf == tmpfile - -class TestStdCaptureFDinvalidFD: - pytestmark = needsdup - def test_stdcapture_fd_invalid_fd(self, testdir): - testdir.makepyfile(""" - import py, os - def test_stdout(): - os.close(1) - cap = py.io.StdCaptureFD(out=True, err=False, in_=False) - cap.done() - def test_stderr(): - os.close(2) - cap = py.io.StdCaptureFD(out=False, err=True, in_=False) - cap.done() - def test_stdin(): - os.close(0) - cap = py.io.StdCaptureFD(out=False, err=False, in_=True) - cap.done() - """) - result = testdir.runpytest("--capture=fd") - assert result.ret == 0 - assert result.parseoutcomes()['passed'] == 3 - -def test_capture_not_started_but_reset(): - capsys = py.io.StdCapture(now=False) - capsys.done() - capsys.done() - capsys.reset() - -@needsdup -def test_capture_no_sys(): - capsys = py.io.StdCapture() - try: - cap = py.io.StdCaptureFD(patchsys=False) - sys.stdout.write("hello") - sys.stderr.write("world") - oswritebytes(1, "1") - oswritebytes(2, "2") - out, err = cap.reset() - assert out == "1" - assert err == "2" - finally: - capsys.reset() - -@needsdup -def test_callcapture_nofd(): - def func(x, y): - oswritebytes(1, "hello") - oswritebytes(2, "hello") - print (x) - sys.stderr.write(str(y)) - return 42 - - capfd = py.io.StdCaptureFD(patchsys=False) - try: - res, out, err = py.io.StdCapture.call(func, 3, y=4) - finally: - capfd.reset() - assert res == 42 - assert out.startswith("3") - assert err.startswith("4") - -@needsdup [email protected](use=[True, False]) -def test_fdcapture_tmpfile_remains_the_same(tmpfile, use): - if not use: - tmpfile = True - cap = py.io.StdCaptureFD(out=False, err=tmpfile, now=False) - cap.startall() - capfile = cap.err.tmpfile - cap.suspend() - cap.resume() - capfile2 = cap.err.tmpfile - assert capfile2 == capfile - [email protected](method=['StdCapture', 'StdCaptureFD']) -def test_capturing_and_logging_fundamentals(testdir, method): - if method == "StdCaptureFD" and not hasattr(os, 'dup'): - py.test.skip("need os.dup") - # here we check a fundamental feature - p = testdir.makepyfile(""" - import sys, os - import py, logging - cap = py.io.%s(out=False, in_=False) - - logging.warn("hello1") - outerr = cap.suspend() - print ("suspend, captured %%s" %%(outerr,)) - logging.warn("hello2") - - cap.resume() - logging.warn("hello3") - - outerr = cap.suspend() - print ("suspend2, captured %%s" %% (outerr,)) - """ % (method,)) - result = testdir.runpython(p) - result.stdout.fnmatch_lines([ - "suspend, captured*hello1*", - "suspend2, captured*hello2*WARNING:root:hello3*", - ]) - assert "atexit" not in result.stderr.str() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/testing/io_/test_saferepr.py new/py-1.4.20/testing/io_/test_saferepr.py --- old/py-1.4.19/testing/io_/test_saferepr.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/testing/io_/test_saferepr.py 2014-01-29 13:16:52.000000000 +0100 @@ -76,18 +76,3 @@ if sys.version_info[0] < 3: u = unicode(excinfo) -def test_unicode_or_repr(): - from py._code.code import unicode_or_repr - assert unicode_or_repr('hello') == "hello" - if sys.version_info[0] < 3: - s = unicode_or_repr('\xf6\xc4\x85') - else: - s = eval("unicode_or_repr(b'\\f6\\xc4\\x85')") - assert 'print-error' in s - assert 'c4' in s - class A: - def __repr__(self): - raise ValueError() - s = unicode_or_repr(A()) - assert 'print-error' in s - assert 'ValueError' in s diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/py-1.4.19/testing/root/test_xmlgen.py new/py-1.4.20/testing/root/test_xmlgen.py --- old/py-1.4.19/testing/root/test_xmlgen.py 2013-12-12 12:07:15.000000000 +0100 +++ new/py-1.4.20/testing/root/test_xmlgen.py 2014-01-29 13:16:52.000000000 +0100 @@ -6,7 +6,7 @@ pass def test_escape(): - uvalue = py.builtin._totext('\xc4\x85\xc4\x87\n', 'utf-8') + uvalue = py.builtin._totext('\xc4\x85\xc4\x87\n\xe2\x82\xac\n', 'utf-8') class A: def __unicode__(self): return uvalue @@ -22,6 +22,8 @@ if py.std.sys.version_info[0] < 3: assert isinstance(x, unicode) assert isinstance(y, unicode) + y = py.xml.escape(uvalue.encode('utf-8')) + assert y == uvalue def test_tag_with_text(): -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
