From 1affd9c8f93fe8985aea2e246aee5122013ad342 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 11 Dec 2020 13:29:37 -0300 Subject: [PATCH] Fix test_comments() in test_source Copied the test as fixed in pytest's repo. --- testing/code/test_source.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/testing/code/test_source.py b/testing/code/test_source.py index caba34b8..d8f1119e 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -497,7 +497,7 @@ def test_oneline_and_comment(): source = getstatement(0, "raise ValueError\n#hello") assert str(source) == "raise ValueError" -def test_comments(): +def test_comments() -> None: source = '''def test(): "comment 1" x = 1 @@ -510,11 +510,17 @@ def test_comments(): comment 4 """ ''' - for line in range(2,6): - assert str(getstatement(line, source)) == ' x = 1' - for line in range(6,10): - assert str(getstatement(line, source)) == ' assert False' - assert str(getstatement(10, source)) == '"""' + for line in range(2, 6): + assert str(getstatement(line, source)) == " x = 1" + if sys.version_info >= (3, 8) or hasattr(sys, "pypy_version_info"): + tqs_start = 8 + else: + tqs_start = 10 + assert str(getstatement(10, source)) == '"""' + for line in range(6, tqs_start): + assert str(getstatement(line, source)) == " assert False" + for line in range(tqs_start, 10): + assert str(getstatement(line, source)) == '"""\ncomment 4\n"""' def test_comment_in_statement(): source = '''test(foo=1,