Skip to content

Commit 7bdaa28

Browse files
FelixSchwarzakx
authored andcommitted
fix tests when using Python 3.9a6
In Python 3.9a6 integer values for future flags were changed to prevent collision with compiler flags. We need to retrieve these at runtime so the test suite works with Python <= 3.8 as well as Python 3.9.
1 parent 167b714 commit 7bdaa28

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

tests/test_util.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# individuals. For the exact contribution history, see the revision
1212
# history and logs, available at http://babel.edgewall.org/log/.
1313

14+
import __future__
1415
import unittest
1516

1617
import pytest
@@ -20,6 +21,12 @@
2021
from babel.util import parse_future_flags
2122

2223

24+
class _FF:
25+
division = __future__.division.compiler_flag
26+
print_function = __future__.print_function.compiler_flag
27+
with_statement = __future__.with_statement.compiler_flag
28+
unicode_literals = __future__.unicode_literals.compiler_flag
29+
2330
def test_distinct():
2431
assert list(util.distinct([1, 2, 1, 3, 4, 4])) == [1, 2, 3, 4]
2532
assert list(util.distinct('foobar')) == ['f', 'o', 'b', 'a', 'r']
@@ -70,25 +77,25 @@ def test_parse_encoding_non_ascii():
7077
from __future__ import print_function,
7178
division, with_statement,
7279
unicode_literals
73-
''', 0x10000 | 0x2000 | 0x8000 | 0x20000),
80+
''', _FF.print_function | _FF.division | _FF.with_statement | _FF.unicode_literals),
7481
('''
7582
from __future__ import print_function, division
7683
print('hello')
77-
''', 0x10000 | 0x2000),
84+
''', _FF.print_function | _FF.division),
7885
('''
7986
from __future__ import print_function, division, unknown,,,,,
8087
print 'hello'
81-
''', 0x10000 | 0x2000),
88+
''', _FF.print_function | _FF.division),
8289
('''
8390
from __future__ import (
8491
print_function,
8592
division)
86-
''', 0x10000 | 0x2000),
93+
''', _FF.print_function | _FF.division),
8794
('''
8895
from __future__ import \\
8996
print_function, \\
9097
division
91-
''', 0x10000 | 0x2000),
98+
''', _FF.print_function | _FF.division),
9299
])
93100
def test_parse_future(source, result):
94101
fp = BytesIO(source.encode('latin-1'))

0 commit comments

Comments
 (0)