1 new commit in pytest: https://bitbucket.org/pytest-dev/pytest/commits/ce106625d6b5/ Changeset: ce106625d6b5 User: flub Date: 2015-04-30 20:13:03+00:00 Summary: Merge fix for issue 731 from pytest-2.7 Affected #: 3 files
diff -r 7d4a0b78d19b985ccca88827129d825151ad494c -r ce106625d6b53f0ff6e9dce8a1cf0c761341b2f4 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -55,6 +55,10 @@ 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 FixtureLookupError which would lead to to an internal error, obfuscating the original problem. Thanks talljosh for initial diff -r 7d4a0b78d19b985ccca88827129d825151ad494c -r ce106625d6b53f0ff6e9dce8a1cf0c761341b2f4 _pytest/assertion/util.py --- a/_pytest/assertion/util.py +++ b/_pytest/assertion/util.py @@ -45,13 +45,15 @@ if where == -1: break level = 0 + prev_c = explanation[start] for i, c in enumerate(explanation[start:]): - if c == "{": + if prev_c + c == "\n{": level += 1 - elif c == "}": + elif prev_c + c == "\n}": level -= 1 if not level: break + prev_c = c else: raise AssertionError("unbalanced braces: %r" % (explanation,)) end = start + i diff -r 7d4a0b78d19b985ccca88827129d825151ad494c -r ce106625d6b53f0ff6e9dce8a1cf0c761341b2f4 testing/test_assertrewrite.py --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -663,3 +663,24 @@ result.stdout.fnmatch_lines([ "* 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}') Repository URL: https://bitbucket.org/pytest-dev/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit