holger krekel avatar holger krekel committed e5594dd

use actually released pytest-2.0.3 / py-1.4.3 versions
(minor fixes compared to the versions pypy already used)

Comments (0)

Files changed (11)

_pytest/__init__.py

 #
-__version__ = '2.0.3.dev3'
+__version__ = '2.0.3'

_pytest/assertion.py

     # 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):
                   '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

_pytest/config.py

         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. """
 
         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. """
         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"):

_pytest/junitxml.py

 
 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",
         del config._xml
         config.pluginmanager.unregister(xml)
 
+
 class LogXML(object):
     def __init__(self, logfile, prefix):
         self.logfile = logfile
         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):
         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")

_pytest/pytester.py

     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

_pytest/resultlog.py

         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):

_pytest/tmpdir.py

         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,
 
 (c) Holger Krekel and others, 2004-2010
 """
-__version__ = '1.4.3.dev0'
+__version__ = '1.4.3'
 
 from py import _apipkg
 

py/_io/terminalwriter.py

         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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.