Correct long-literals for Python 2.7

This commit is contained in:
rocky
2022-10-16 19:33:51 -04:00
parent bb9b9fb4b3
commit 5b3ea47bac
8 changed files with 26 additions and 11 deletions

View File

@@ -161,7 +161,9 @@ x = {
"return": 12,
}
assert tuple(x.keys()) == ("b", "c", "e", "g", "h", "j", "k", "return")
# We need sorted here and below, because x.keys() in 2.7 comes out in the reverse order.
# Go figure.
assert sorted(x.keys()) == ["b", "c", "e", "g", "h", "j", "k", "return"]
# Ensure that in dictionary we produce integers, not strings
x = {1: 2, 3: 4}
@@ -675,7 +677,12 @@ values = {
"value502": 502 + 1,
}
assert list(values.values())[1:] == list(range(3, 502 + 2))
import sys
if sys.version < (3, 0):
# Python 2.7 is funky with values.values() ordering
assert sorted(values.values())[1:-2] == list(range(4, 502 + 1))
else:
assert list(values.values())[1:] == list(range(3, 502 + 2))
# Try a long dictionary that fails because we have a binary op.
# We can get a expr32 grouping speedup
@@ -717,4 +724,4 @@ values = {
"value33": 33,
}
assert list(values.values())[1:] == list(range(2, 34))
assert sorted(values.values())[1:] == list(range(2, 34))