merge default

--HG--
branch : pluggy1
This commit is contained in:
holger krekel 2015-05-05 14:52:16 +02:00
commit a4f2236b36
4 changed files with 31 additions and 4 deletions

View File

@ -55,6 +55,10 @@
2.7.1.dev (compared to 2.7.0) 2.7.1.dev (compared to 2.7.0)
----------------------------- -----------------------------
- fix issue731: do not get confused by the braces which may be present
and unbalanced in an object's repr while collapsing False
explanations. Thanks Carl Meyer for the report and test case.
- fix issue553: properly handling inspect.getsourcelines failures in - fix issue553: properly handling inspect.getsourcelines failures in
FixtureLookupError which would lead to to an internal error, FixtureLookupError which would lead to to an internal error,
obfuscating the original problem. Thanks talljosh for initial obfuscating the original problem. Thanks talljosh for initial

View File

@ -45,13 +45,15 @@ def _collapse_false(explanation):
if where == -1: if where == -1:
break break
level = 0 level = 0
prev_c = explanation[start]
for i, c in enumerate(explanation[start:]): for i, c in enumerate(explanation[start:]):
if c == "{": if prev_c + c == "\n{":
level += 1 level += 1
elif c == "}": elif prev_c + c == "\n}":
level -= 1 level -= 1
if not level: if not level:
break break
prev_c = c
else: else:
raise AssertionError("unbalanced braces: %r" % (explanation,)) raise AssertionError("unbalanced braces: %r" % (explanation,))
end = start + i end = start + i

View File

@ -177,8 +177,8 @@ class monkeypatch:
sys.path.insert(0, str(path)) sys.path.insert(0, str(path))
def chdir(self, path): def chdir(self, path):
""" Change the current working directory to the specified path """ Change the current working directory to the specified path.
path can be a string or a py.path.local object Path can be a string or a py.path.local object.
""" """
if self._cwd is None: if self._cwd is None:
self._cwd = os.getcwd() self._cwd = os.getcwd()

View File

@ -663,3 +663,24 @@ class TestAssertionRewriteHookDetails(object):
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"* 1 passed*", "* 1 passed*",
]) ])
def test_issue731(testdir):
testdir.makepyfile("""
class LongReprWithBraces(object):
def __repr__(self):
return 'LongReprWithBraces({' + ('a' * 80) + '}' + ('a' * 120) + ')'
def some_method(self):
return False
def test_long_repr():
obj = LongReprWithBraces()
assert obj.some_method()
""")
result = testdir.runpytest()
assert 'unbalanced braces' not in result.stdout.str()
def test_collapse_false_unbalanced_braces():
util._collapse_false('some text{ False\n{False = some more text\n}')