Skip to content

Commit 9793cc2

Browse files
committed
fix style, run tests only on 3.8+
1 parent c3dd538 commit 9793cc2

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/parser/AssignmentTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0

graalpython/com.oracle.graal.python.test/src/tests/test_parser.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -130,29 +130,31 @@ def foo(object: object):
130130

131131

132132
def test_cannot_assign():
133-
def assert_raise(s, msg):
134-
try:
135-
compile("%s = 1" % s, "", "single")
136-
except SyntaxError as e:
137-
assert msg in str(e), str(e)
138-
else:
139-
assert False
140-
try:
141-
compile("with foo as %s:\n pass" % s, "", "single")
142-
except SyntaxError as e:
143-
assert msg in str(e), str(e)
144-
else:
145-
assert False
146-
assert_raise("None", "cannot assign to None")
147-
assert_raise("1", "cannot assign to literal")
148-
assert_raise("1.1", "cannot assign to literal")
149-
assert_raise("{1}", "cannot assign to set display")
150-
assert_raise("{1: 2}", "cannot assign to dict display")
151-
assert_raise("1.2j", "cannot assign to literal")
152-
assert_raise("...", "cannot assign to Ellipsis")
153-
assert_raise("True", "cannot assign to True")
154-
assert_raise("False", "cannot assign to False")
155-
assert_raise("b''", "cannot assign to literal")
156-
assert_raise("''", "cannot assign to literal")
157-
assert_raise("f''", "cannot assign to f-string expression")
158-
assert_raise("(None,)", "cannot assign to None")
133+
import sys
134+
if sys.implementation.version.minor >= 8:
135+
def assert_raise(s, msg):
136+
try:
137+
compile("%s = 1" % s, "", "single")
138+
except SyntaxError as e:
139+
assert msg in str(e), str(e)
140+
else:
141+
assert False
142+
try:
143+
compile("with foo as %s:\n pass" % s, "", "single")
144+
except SyntaxError as e:
145+
assert msg in str(e), str(e)
146+
else:
147+
assert False
148+
assert_raise("None", "cannot assign to None")
149+
assert_raise("1", "cannot assign to literal")
150+
assert_raise("1.1", "cannot assign to literal")
151+
assert_raise("{1}", "cannot assign to set display")
152+
assert_raise("{1: 2}", "cannot assign to dict display")
153+
assert_raise("1.2j", "cannot assign to literal")
154+
assert_raise("...", "cannot assign to Ellipsis")
155+
assert_raise("True", "cannot assign to True")
156+
assert_raise("False", "cannot assign to False")
157+
assert_raise("b''", "cannot assign to literal")
158+
assert_raise("''", "cannot assign to literal")
159+
assert_raise("f''", "cannot assign to f-string expression")
160+
assert_raise("(None,)", "cannot assign to None")

0 commit comments

Comments
 (0)