merge next chunk from master and fix changelog linting issue

This commit is contained in:
Ronny Pfannschmidt 2016-05-13 19:36:13 +02:00
commit c49863aa63
7 changed files with 62 additions and 20 deletions

View File

@ -62,6 +62,7 @@ Marc Schlaich
Mark Abramowitz Mark Abramowitz
Markus Unterwaditzer Markus Unterwaditzer
Martijn Faassen Martijn Faassen
Martin Prusse
Matt Bachmann Matt Bachmann
Matt Williams Matt Williams
Michael Aquilina Michael Aquilina

View File

@ -77,6 +77,10 @@
* *
* Fix maximum recursion depth detection when raised error class is not aware
of unicode/encoded bytes.
Thanks `@prusse-martin`_ for the PR (`#1506`_).
* Fix ``pytest.mark.skip`` mark when used in strict mode. * Fix ``pytest.mark.skip`` mark when used in strict mode.
Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for
showing how to fix the bug. showing how to fix the bug.
@ -85,6 +89,11 @@
Thanks `@omarkohl`_ for the PR. Thanks `@omarkohl`_ for the PR.
.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
.. _@prusse-martin: https://github.com/prusse-martin
2.9.1 2.9.1
===== =====
@ -238,7 +247,6 @@
.. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt .. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
.. _@rabbbit: https://github.com/rabbbit .. _@rabbbit: https://github.com/rabbbit
.. _@hackebrot: https://github.com/hackebrot .. _@hackebrot: https://github.com/hackebrot
.. _@omarkohl: https://github.com/omarkohl
.. _@pquentin: https://github.com/pquentin .. _@pquentin: https://github.com/pquentin
2.8.7 2.8.7

View File

@ -603,8 +603,7 @@ class FormattedExcinfo(object):
if self.tbfilter: if self.tbfilter:
traceback = traceback.filter() traceback = traceback.filter()
recursionindex = None recursionindex = None
if excinfo.errisinstance(RuntimeError): if is_recursion_error(excinfo):
if "maximum recursion depth exceeded" in str(excinfo.value):
recursionindex = traceback.recursionindex() recursionindex = traceback.recursionindex()
last = traceback[-1] last = traceback[-1]
entries = [] entries = []
@ -867,3 +866,14 @@ def getrawcode(obj, trycall=True):
return x return x
return obj return obj
if sys.version_info[:2] >= (3, 5): # RecursionError introduced in 3.5
def is_recursion_error(excinfo):
return excinfo.errisinstance(RecursionError) # noqa
else:
def is_recursion_error(excinfo):
if not excinfo.errisinstance(RuntimeError):
return False
try:
return "maximum recursion depth exceeded" in str(excinfo.value)
except UnicodeError:
return False

View File

@ -58,7 +58,7 @@ pytest_cmdline_main.tryfirst = True
def pytest_collection_modifyitems(items, config): def pytest_collection_modifyitems(items, config):
keywordexpr = config.option.keyword keywordexpr = config.option.keyword.lstrip()
matchexpr = config.option.markexpr matchexpr = config.option.markexpr
if not keywordexpr and not matchexpr: if not keywordexpr and not matchexpr:
return return

View File

@ -158,7 +158,7 @@ To get a list of the slowest 10 test durations::
Creating JUnitXML format files Creating JUnitXML format files
---------------------------------------------------- ----------------------------------------------------
To create result files which can be read by Hudson_ or other Continuous To create result files which can be read by Jenkins_ or other Continuous
integration servers, use this invocation:: integration servers, use this invocation::
py.test --junitxml=path py.test --junitxml=path

View File

@ -671,6 +671,11 @@ class TestDurations:
"*call*test_1*", "*call*test_1*",
]) ])
def test_with_not(self, testdir):
testdir.makepyfile(self.source)
result = testdir.runpytest("-k not 1")
assert result.ret == 0
class TestDurationWithFixture: class TestDurationWithFixture:
source = """ source = """

View File

@ -4,7 +4,10 @@ import operator
import _pytest import _pytest
import py import py
import pytest import pytest
from _pytest._code.code import (FormattedExcinfo, ReprExceptionInfo, from _pytest._code.code import (
ExceptionInfo,
FormattedExcinfo,
ReprExceptionInfo,
ExceptionChainRepr) ExceptionChainRepr)
queue = py.builtin._tryimport('queue', 'Queue') queue = py.builtin._tryimport('queue', 'Queue')
@ -1048,3 +1051,18 @@ raise ValueError()
assert tw.lines[40] == "E AttributeError" assert tw.lines[40] == "E AttributeError"
assert tw.lines[41] == "" assert tw.lines[41] == ""
assert tw.lines[42].endswith("mod.py:15: AttributeError") assert tw.lines[42].endswith("mod.py:15: AttributeError")
@pytest.mark.parametrize("style", ["short", "long"])
@pytest.mark.parametrize("encoding", [None, "utf8", "utf16"])
def test_repr_traceback_with_unicode(style, encoding):
msg = u''
if encoding is not None:
msg = msg.encode(encoding)
try:
raise RuntimeError(msg)
except RuntimeError:
e_info = ExceptionInfo()
formatter = FormattedExcinfo(style=style)
repr_traceback = formatter.repr_traceback(e_info)
assert repr_traceback is not None