Correcting implementation based on pull request feed back
This commit is contained in:
parent
24212fd97f
commit
2ddbac1f98
1
AUTHORS
1
AUTHORS
|
@ -60,3 +60,4 @@ Samuele Pedroni
|
||||||
Tom Viner
|
Tom Viner
|
||||||
Trevor Bekolay
|
Trevor Bekolay
|
||||||
Wouter van Ackooy
|
Wouter van Ackooy
|
||||||
|
David Díaz-Barquero
|
||||||
|
|
|
@ -138,6 +138,9 @@
|
||||||
- fix issue890: changed extension of all documentation files from ``txt`` to
|
- fix issue890: changed extension of all documentation files from ``txt`` to
|
||||||
``rst``. Thanks to Abhijeet for the PR.
|
``rst``. Thanks to Abhijeet for the PR.
|
||||||
|
|
||||||
|
- implement feature on issue951: support to log additional information on xml
|
||||||
|
output.
|
||||||
|
|
||||||
2.7.3 (compared to 2.7.2)
|
2.7.3 (compared to 2.7.2)
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import pytest
|
||||||
|
|
||||||
# Python 2.X and 3.X compatibility
|
# Python 2.X and 3.X compatibility
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
|
@ -53,12 +54,13 @@ def bin_xml_escape(arg):
|
||||||
return unicode('#x%04X') % i
|
return unicode('#x%04X') % i
|
||||||
return py.xml.raw(illegal_xml_re.sub(repl, py.xml.escape(arg)))
|
return py.xml.raw(illegal_xml_re.sub(repl, py.xml.escape(arg)))
|
||||||
|
|
||||||
def record_property(name, value):
|
@pytest.fixture
|
||||||
if hasattr(record_property, 'binding'):
|
def record_xml_property(request):
|
||||||
record_property.binding(name, value)
|
if hasattr(request.config, "_xml"):
|
||||||
|
return request.config._xml.record_property
|
||||||
def pytest_namespace():
|
def dummy(*args, **kwargs):
|
||||||
return dict(record_property=record_property)
|
pass
|
||||||
|
return dummy
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
group = parser.getgroup("terminal reporting")
|
group = parser.getgroup("terminal reporting")
|
||||||
|
@ -76,18 +78,12 @@ def pytest_configure(config):
|
||||||
config._xml = LogXML(xmlpath, config.option.junitprefix)
|
config._xml = LogXML(xmlpath, config.option.junitprefix)
|
||||||
config.pluginmanager.register(config._xml)
|
config.pluginmanager.register(config._xml)
|
||||||
|
|
||||||
def binding(name, value):
|
|
||||||
config._xml.record_property(name, value)
|
|
||||||
record_property.binding = binding
|
|
||||||
|
|
||||||
def pytest_unconfigure(config):
|
def pytest_unconfigure(config):
|
||||||
xml = getattr(config, '_xml', None)
|
xml = getattr(config, '_xml', None)
|
||||||
if xml:
|
if xml:
|
||||||
del config._xml
|
del config._xml
|
||||||
config.pluginmanager.unregister(xml)
|
config.pluginmanager.unregister(xml)
|
||||||
|
|
||||||
del record_property.binding
|
|
||||||
|
|
||||||
def mangle_testnames(names):
|
def mangle_testnames(names):
|
||||||
names = [x.replace(".py", "") for x in names if x != '()']
|
names = [x.replace(".py", "") for x in names if x != '()']
|
||||||
names[0] = names[0].replace("/", '.')
|
names[0] = names[0].replace("/", '.')
|
||||||
|
|
|
@ -162,6 +162,8 @@ record_property("key", value)::
|
||||||
pytest.record_property("example_key", 1)
|
pytest.record_property("example_key", 1)
|
||||||
...
|
...
|
||||||
|
|
||||||
|
Warning: using this feature will break any schema verification.
|
||||||
|
|
||||||
Creating resultlog format files
|
Creating resultlog format files
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -554,9 +554,8 @@ def test_unicode_issue368(testdir):
|
||||||
|
|
||||||
def test_record_property(testdir):
|
def test_record_property(testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
from pytest import record_property
|
def test_record(record_xml_property):
|
||||||
def test_record():
|
record_xml_property("foo", "<1");
|
||||||
record_property("foo", "<1");
|
|
||||||
""")
|
""")
|
||||||
result, dom = runandparse(testdir)
|
result, dom = runandparse(testdir)
|
||||||
node = dom.getElementsByTagName("testsuite")[0]
|
node = dom.getElementsByTagName("testsuite")[0]
|
||||||
|
|
Loading…
Reference in New Issue