Merge branch 'master' into merge-master

This commit is contained in:
Ronny Pfannschmidt 2016-05-13 19:37:41 +02:00
commit eab762ea99
9 changed files with 38 additions and 25 deletions

View File

@ -49,6 +49,7 @@ Jaap Broekhuizen
Jan Balster Jan Balster
Janne Vanhala Janne Vanhala
Jason R. Coombs Jason R. Coombs
John Towler
Joshua Bronson Joshua Bronson
Jurko Gospodnetić Jurko Gospodnetić
Katarzyna Jachim Katarzyna Jachim
@ -93,3 +94,4 @@ Russel Winder
Ben Webb Ben Webb
Alexei Kozlenok Alexei Kozlenok
Cal Leeming Cal Leeming
Feng Ma

View File

@ -75,7 +75,8 @@
* When receiving identical test ids in parametrize we generate unique test ids. * When receiving identical test ids in parametrize we generate unique test ids.
* * Fix win32 path issue when puttinging custom config file with absolute path
in ``pytest.main("-c your_absolute_path")``.
* Fix maximum recursion depth detection when raised error class is not aware * Fix maximum recursion depth detection when raised error class is not aware
of unicode/encoded bytes. of unicode/encoded bytes.

View File

@ -305,11 +305,11 @@ class Traceback(list):
def filter(self, fn=lambda x: not x.ishidden()): def filter(self, fn=lambda x: not x.ishidden()):
""" return a Traceback instance with certain items removed """ return a Traceback instance with certain items removed
fn is a function that gets a single argument, a TracebackItem fn is a function that gets a single argument, a TracebackEntry
instance, and should return True when the item should be added instance, and should return True when the item should be added
to the Traceback, False when not to the Traceback, False when not
by default this removes all the TracebackItems which are hidden by default this removes all the TracebackEntries which are hidden
(see ishidden() above) (see ishidden() above)
""" """
return Traceback(filter(fn, self), self._excinfo) return Traceback(filter(fn, self), self._excinfo)
@ -325,7 +325,7 @@ class Traceback(list):
return self[-1] return self[-1]
def recursionindex(self): def recursionindex(self):
""" return the index of the frame/TracebackItem where recursion """ return the index of the frame/TracebackEntry where recursion
originates if appropriate, None if no recursion occurred originates if appropriate, None if no recursion occurred
""" """
cache = {} cache = {}

View File

@ -104,7 +104,7 @@ def _prepareconfig(args=None, plugins=None):
elif not isinstance(args, (tuple, list)): elif not isinstance(args, (tuple, list)):
if not isinstance(args, str): if not isinstance(args, str):
raise ValueError("not a string or argument list: %r" % (args,)) raise ValueError("not a string or argument list: %r" % (args,))
args = shlex.split(args) args = shlex.split(args, posix=sys.platform == "win32")
config = get_config() config = get_config()
pluginmanager = config.pluginmanager pluginmanager = config.pluginmanager
try: try:

View File

@ -373,7 +373,7 @@ class LogXML(object):
suite_stop_time = time.time() suite_stop_time = time.time()
suite_time_delta = suite_stop_time - self.suite_start_time suite_time_delta = suite_stop_time - self.suite_start_time
numtests = self.stats['passed'] + self.stats['failure'] numtests = self.stats['passed'] + self.stats['failure'] + self.stats['skipped']
logfile.write('<?xml version="1.0" encoding="utf-8"?>') logfile.write('<?xml version="1.0" encoding="utf-8"?>')

View File

@ -1746,7 +1746,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
self._pyfuncitem = pyfuncitem self._pyfuncitem = pyfuncitem
#: fixture for which this request is being performed #: fixture for which this request is being performed
self.fixturename = None self.fixturename = None
#: Scope string, one of "function", "cls", "module", "session" #: Scope string, one of "function", "class", "module", "session"
self.scope = "function" self.scope = "function"
self._funcargs = {} self._funcargs = {}
self._fixturedefs = {} self._fixturedefs = {}

View File

@ -9,19 +9,19 @@ by passing the ``--ignore=path`` option on the cli. ``pytest`` allows multiple
``--ignore`` options. Example:: ``--ignore`` options. Example::
tests/ tests/
├── example |-- example
│   ├── test_example_01.py | |-- test_example_01.py
│   ├── test_example_02.py | |-- test_example_02.py
│   └── test_example_03.py | '-- test_example_03.py
├── foobar |-- foobar
│   ├── test_foobar_01.py | |-- test_foobar_01.py
│   ├── test_foobar_02.py | |-- test_foobar_02.py
│   └── test_foobar_03.py | '-- test_foobar_03.py
└── hello '-- hello
└── world '-- world
├── test_world_01.py |-- test_world_01.py
├── test_world_02.py |-- test_world_02.py
└── test_world_03.py '-- test_world_03.py
Now if you invoke ``pytest`` with ``--ignore=tests/foobar/test_foobar_03.py --ignore=tests/hello/``, Now if you invoke ``pytest`` with ``--ignore=tests/foobar/test_foobar_03.py --ignore=tests/hello/``,
you will see that ``pytest`` only collects test-modules, which do not match the patterns specified:: you will see that ``pytest`` only collects test-modules, which do not match the patterns specified::

View File

@ -101,6 +101,16 @@ class TestConfigCmdlineParsing:
config = testdir.parseconfig("-c", "custom.cfg") config = testdir.parseconfig("-c", "custom.cfg")
assert config.getini("custom") == "1" assert config.getini("custom") == "1"
def test_absolute_win32_path(self, testdir):
temp_cfg_file = testdir.makefile(".cfg", custom="""
[pytest]
addopts = --version
""")
from os.path import normpath
temp_cfg_file = normpath(str(temp_cfg_file))
ret = pytest.main("-c " + temp_cfg_file)
assert ret == _pytest.main.EXIT_OK
class TestConfigAPI: class TestConfigAPI:
def test_config_trace(self, testdir): def test_config_trace(self, testdir):
config = testdir.parseconfig() config = testdir.parseconfig()

View File

@ -100,7 +100,7 @@ class TestPython:
result, dom = runandparse(testdir) result, dom = runandparse(testdir)
assert result.ret assert result.ret
node = dom.find_first_by_tag("testsuite") node = dom.find_first_by_tag("testsuite")
node.assert_attr(name="pytest", errors=0, failures=1, skips=3, tests=2) node.assert_attr(name="pytest", errors=0, failures=1, skips=3, tests=5)
def test_timing_function(self, testdir): def test_timing_function(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
@ -304,7 +304,7 @@ class TestPython:
result, dom = runandparse(testdir) result, dom = runandparse(testdir)
assert not result.ret assert not result.ret
node = dom.find_first_by_tag("testsuite") node = dom.find_first_by_tag("testsuite")
node.assert_attr(skips=1, tests=0) node.assert_attr(skips=1, tests=1)
tnode = node.find_first_by_tag("testcase") tnode = node.find_first_by_tag("testcase")
tnode.assert_attr( tnode.assert_attr(
file="test_xfailure_function.py", file="test_xfailure_function.py",
@ -325,7 +325,7 @@ class TestPython:
result, dom = runandparse(testdir) result, dom = runandparse(testdir)
# assert result.ret # assert result.ret
node = dom.find_first_by_tag("testsuite") node = dom.find_first_by_tag("testsuite")
node.assert_attr(skips=1, tests=0) node.assert_attr(skips=1, tests=1)
tnode = node.find_first_by_tag("testcase") tnode = node.find_first_by_tag("testcase")
tnode.assert_attr( tnode.assert_attr(
file="test_xfailure_xpass.py", file="test_xfailure_xpass.py",
@ -356,7 +356,7 @@ class TestPython:
result, dom = runandparse(testdir) result, dom = runandparse(testdir)
assert result.ret == EXIT_NOTESTSCOLLECTED assert result.ret == EXIT_NOTESTSCOLLECTED
node = dom.find_first_by_tag("testsuite") node = dom.find_first_by_tag("testsuite")
node.assert_attr(skips=1, tests=0) node.assert_attr(skips=1, tests=1)
tnode = node.find_first_by_tag("testcase") tnode = node.find_first_by_tag("testcase")
tnode.assert_attr( tnode.assert_attr(
file="test_collect_skipped.py", file="test_collect_skipped.py",