fixes issue113 - assertion represenation issue

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-07-29 12:55:39 +02:00
parent 92bfb58798
commit efeae72509
4 changed files with 26 additions and 9 deletions

View File

@ -1,6 +1,8 @@
Changes between 1.3.2 and 1.3.3a1 Changes between 1.3.2 and 1.3.3a1
================================================== ==================================================
- fix issue113: assertion representation problem with triple-quoted strings
(and possibly other cases)
- make conftest loading detect that a conftest file with the same - make conftest loading detect that a conftest file with the same
content was already loaded, avoids surprises in nested directory structures content was already loaded, avoids surprises in nested directory structures
that can be produced e.g. by Hudson. It alleviates the need to use that can be produced e.g. by Hudson. It alleviates the need to use

View File

@ -125,16 +125,13 @@ class Source(object):
try: try:
compile_command(trysource) compile_command(trysource)
except (SyntaxError, OverflowError, ValueError): except (SyntaxError, OverflowError, ValueError):
pass continue
else:
break # got a valid or incomplete statement
# 2. find the end of the statement # 2. find the end of the statement
for end in range(lineno+1, len(self)+1): for end in range(lineno+1, len(self)+1):
trysource = self[start:end] trysource = self[start:end]
if trysource.isparseable(): if trysource.isparseable():
break return start, end
return start, end return start, end
def getblockend(self, lineno): def getblockend(self, lineno):

View File

@ -176,6 +176,13 @@ class TestSourceParsingAndCompiling:
#x = s.deindent() #x = s.deindent()
assert str(s) == ass assert str(s) == ass
def test_getstatementrange_triple_quoted(self):
#print str(self.source)
source = Source("""'''
'''""")
s = source.getstatement(1)
assert eval(str(s))
def test_getstatementrange_within_constructs(self): def test_getstatementrange_within_constructs(self):
source = Source("""\ source = Source("""\
try: try:

View File

@ -9,6 +9,17 @@ def test_functional(testdir):
result = testdir.runpytest("--no-assert") result = testdir.runpytest("--no-assert")
assert "3 == 4" not in result.stdout.str() assert "3 == 4" not in result.stdout.str()
def test_triple_quoted_string_issue113(testdir):
testdir.makepyfile("""
def test_hello():
assert "" == '''
'''""")
result = testdir.runpytest("--fulltrace")
result.stdout.fnmatch_lines([
"*1 failed*",
])
assert 'SyntaxError' not in result.stdout.str()
def test_traceback_failure(testdir): def test_traceback_failure(testdir):
p1 = testdir.makepyfile(""" p1 = testdir.makepyfile("""
def g(): def g():