Finally fix Python 2.6.

Also added a syntax for 2.6. There are some thing that just don't work in 2.6.
This commit is contained in:
Dave Halter
2017-07-31 21:31:26 +02:00
parent ddd16124ac
commit d6c624bd34
7 changed files with 185 additions and 14 deletions

View File

@@ -166,17 +166,17 @@ def test_except_old(works_in_py2):
# Adapted from Python 3's Lib/test/test_grammar.py:GrammarTests.testAtoms
def test_set_literal_1(each_version):
_parse("""x = {'one'}""", each_version)
def test_set_literal_1(works_ge_py27):
works_ge_py27.parse("""x = {'one'}""")
def test_set_literal_2(each_version):
_parse("""x = {'one', 1,}""", each_version)
def test_set_literal_2(works_ge_py27):
works_ge_py27.parse("""x = {'one', 1,}""")
def test_set_literal_3(each_version):
_parse("""x = {'one', 'two', 'three'}""", each_version)
def test_set_literal_3(works_ge_py27):
works_ge_py27.parse("""x = {'one', 'two', 'three'}""")
def test_set_literal_4(each_version):
_parse("""x = {2, 3, 4,}""", each_version)
def test_set_literal_4(works_ge_py27):
works_ge_py27.parse("""x = {2, 3, 4,}""")
def test_new_octal_notation(each_version):

View File

@@ -58,7 +58,6 @@ FAILING_EXAMPLES = [
'a, b += 3',
'(a, b) += 3',
'[a, b] += 3',
'[a, 1] += 3',
# All assignment tests
'lambda a: 1 = 1',
'[x for x in y] = 1',
@@ -221,6 +220,10 @@ if sys.version_info >= (3,):
# A symtable error that raises only a SyntaxWarning in Python 2.
'def x(): from math import *',
]
if sys.version_info >= (2, 7):
# This is something that raises a different error in 2.6 than in the other
# versions. Just skip it for 2.6.
FAILING_EXAMPLES.append('[a, 1] += 3')
def _get_error_list(code, version=None):
@@ -306,6 +309,12 @@ def _get_actual_exception(code):
wanted = 'SyntaxError: positional argument follows keyword argument'
elif wanted == 'SyntaxError: assignment to keyword':
return [wanted, "SyntaxError: can't assign to keyword"], line_nr
elif wanted == 'SyntaxError: assignment to None':
# Python 2.6 does has a slightly different error.
return [wanted, 'SyntaxError: cannot assign to None'], line_nr
elif wanted == 'SyntaxError: can not assign to __debug__':
# Python 2.6 does has a slightly different error.
return [wanted, 'SyntaxError: cannot assign to __debug__'], line_nr
return [wanted], line_nr