fix unicode handling with junitxml, fixes issue368.
This commit is contained in:
parent
0d8392bc45
commit
cf9d345382
|
@ -4,6 +4,8 @@ Changes between 2.4.2 and 2.4.3
|
||||||
- fix unicode handling with new monkeypatch.setattr(import_path, value)
|
- fix unicode handling with new monkeypatch.setattr(import_path, value)
|
||||||
API. Thanks Rob Dennis. Fixes issue371.
|
API. Thanks Rob Dennis. Fixes issue371.
|
||||||
|
|
||||||
|
- fix unicode handling with junitxml, fixes issue368.
|
||||||
|
|
||||||
- In assertion rewriting mode on Python 2, fix the detection of coding
|
- In assertion rewriting mode on Python 2, fix the detection of coding
|
||||||
cookies. See issue #330.
|
cookies. See issue #330.
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#
|
#
|
||||||
__version__ = '2.4.3.dev1'
|
__version__ = '2.4.3.dev2'
|
||||||
|
|
|
@ -9,7 +9,6 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
# Python 2.X and 3.X compatibility
|
# Python 2.X and 3.X compatibility
|
||||||
try:
|
try:
|
||||||
unichr(65)
|
unichr(65)
|
||||||
|
@ -131,31 +130,31 @@ class LogXML(object):
|
||||||
self.skipped += 1
|
self.skipped += 1
|
||||||
else:
|
else:
|
||||||
fail = Junit.failure(message="test failure")
|
fail = Junit.failure(message="test failure")
|
||||||
fail.append(str(report.longrepr))
|
fail.append(unicode(report.longrepr))
|
||||||
self.append(fail)
|
self.append(fail)
|
||||||
self.failed += 1
|
self.failed += 1
|
||||||
self._write_captured_output(report)
|
self._write_captured_output(report)
|
||||||
|
|
||||||
def append_collect_failure(self, report):
|
def append_collect_failure(self, report):
|
||||||
#msg = str(report.longrepr.reprtraceback.extraline)
|
#msg = str(report.longrepr.reprtraceback.extraline)
|
||||||
self.append(Junit.failure(str(report.longrepr),
|
self.append(Junit.failure(unicode(report.longrepr),
|
||||||
message="collection failure"))
|
message="collection failure"))
|
||||||
self.errors += 1
|
self.errors += 1
|
||||||
|
|
||||||
def append_collect_skipped(self, report):
|
def append_collect_skipped(self, report):
|
||||||
#msg = str(report.longrepr.reprtraceback.extraline)
|
#msg = str(report.longrepr.reprtraceback.extraline)
|
||||||
self.append(Junit.skipped(str(report.longrepr),
|
self.append(Junit.skipped(unicode(report.longrepr),
|
||||||
message="collection skipped"))
|
message="collection skipped"))
|
||||||
self.skipped += 1
|
self.skipped += 1
|
||||||
|
|
||||||
def append_error(self, report):
|
def append_error(self, report):
|
||||||
self.append(Junit.error(str(report.longrepr),
|
self.append(Junit.error(unicode(report.longrepr),
|
||||||
message="test setup failure"))
|
message="test setup failure"))
|
||||||
self.errors += 1
|
self.errors += 1
|
||||||
|
|
||||||
def append_skipped(self, report):
|
def append_skipped(self, report):
|
||||||
if hasattr(report, "wasxfail"):
|
if hasattr(report, "wasxfail"):
|
||||||
self.append(Junit.skipped(str(report.wasxfail),
|
self.append(Junit.skipped(unicode(report.wasxfail),
|
||||||
message="expected test failure"))
|
message="expected test failure"))
|
||||||
else:
|
else:
|
||||||
filename, lineno, skipreason = report.longrepr
|
filename, lineno, skipreason = report.longrepr
|
||||||
|
@ -201,10 +200,10 @@ class LogXML(object):
|
||||||
classname="pytest",
|
classname="pytest",
|
||||||
name="internal"))
|
name="internal"))
|
||||||
|
|
||||||
def pytest_sessionstart(self, session):
|
def pytest_sessionstart(self):
|
||||||
self.suite_start_time = time.time()
|
self.suite_start_time = time.time()
|
||||||
|
|
||||||
def pytest_sessionfinish(self, session, exitstatus, __multicall__):
|
def pytest_sessionfinish(self):
|
||||||
if py.std.sys.version_info[0] < 3:
|
if py.std.sys.version_info[0] < 3:
|
||||||
logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
|
logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
|
||||||
else:
|
else:
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -27,7 +27,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.4.3.dev1',
|
version='2.4.3.dev2',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
import py, sys, os
|
import py, sys, os
|
||||||
|
from _pytest.junitxml import LogXML
|
||||||
|
|
||||||
def runandparse(testdir, *args):
|
def runandparse(testdir, *args):
|
||||||
resultpath = testdir.tmpdir.join("junit.xml")
|
resultpath = testdir.tmpdir.join("junit.xml")
|
||||||
|
@ -423,8 +426,6 @@ def test_invalid_xml_escape():
|
||||||
assert chr(i) == bin_xml_escape(unichr(i)).uniobj
|
assert chr(i) == bin_xml_escape(unichr(i)).uniobj
|
||||||
|
|
||||||
def test_logxml_path_expansion(tmpdir, monkeypatch):
|
def test_logxml_path_expansion(tmpdir, monkeypatch):
|
||||||
from _pytest.junitxml import LogXML
|
|
||||||
|
|
||||||
home_tilde = py.path.local(os.path.expanduser('~')).join('test.xml')
|
home_tilde = py.path.local(os.path.expanduser('~')).join('test.xml')
|
||||||
|
|
||||||
xml_tilde = LogXML('~%stest.xml' % tmpdir.sep, None)
|
xml_tilde = LogXML('~%stest.xml' % tmpdir.sep, None)
|
||||||
|
@ -461,3 +462,25 @@ def test_escaped_parametrized_names_xml(testdir):
|
||||||
assert_attr(node,
|
assert_attr(node,
|
||||||
name="test_func[#x00]")
|
name="test_func[#x00]")
|
||||||
|
|
||||||
|
def test_unicode_issue368(testdir):
|
||||||
|
path = testdir.tmpdir.join("test.xml")
|
||||||
|
log = LogXML(str(path), None)
|
||||||
|
class report:
|
||||||
|
longrepr = u"ВНИМАНИЕ!"
|
||||||
|
sections = []
|
||||||
|
nodeid = "something"
|
||||||
|
|
||||||
|
# hopefully this is not too brittle ...
|
||||||
|
log.pytest_sessionstart()
|
||||||
|
log._opentestcase(report)
|
||||||
|
log.append_failure(report)
|
||||||
|
log.append_collect_failure(report)
|
||||||
|
log.append_collect_skipped(report)
|
||||||
|
log.append_error(report)
|
||||||
|
report.longrepr = "filename", 1, u"ВНИМАНИЕ!"
|
||||||
|
log.append_skipped(report)
|
||||||
|
report.wasxfail = u"ВНИМАНИЕ!"
|
||||||
|
log.append_skipped(report)
|
||||||
|
log.pytest_sessionfinish()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue