Skip to content

Commit e94e670

Browse files
committed
Fix test_comments() in test_source
Copied the test as fixed in pytest's repo.
1 parent fef9a32 commit e94e670

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

testing/code/test_source.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,17 @@ def test_comments():
510510
comment 4
511511
"""
512512
'''
513-
for line in range(2,6):
514-
assert str(getstatement(line, source)) == ' x = 1'
515-
for line in range(6,10):
516-
assert str(getstatement(line, source)) == ' assert False'
517-
assert str(getstatement(10, source)) == '"""'
513+
for line in range(2, 6):
514+
assert str(getstatement(line, source)) == " x = 1"
515+
if sys.version_info >= (3, 8) or hasattr(sys, "pypy_version_info"):
516+
tqs_start = 8
517+
else:
518+
tqs_start = 10
519+
assert str(getstatement(10, source)) == '"""'
520+
for line in range(6, tqs_start):
521+
assert str(getstatement(line, source)) == " assert False"
522+
for line in range(tqs_start, 10):
523+
assert str(getstatement(line, source)) == '"""\ncomment 4\n"""'
518524

519525
def test_comment_in_statement():
520526
source = '''test(foo=1,

0 commit comments

Comments
 (0)