@@ -70,10 +70,16 @@ class TestAssertionRewrite(object):
70
70
def test_place_initial_imports (self ):
71
71
s = """'Doc string'\n other = stuff"""
72
72
m = rewrite (s )
73
- # Module docstrings in 3.7 are part of Module node, it's not in the body
73
+ # Module docstrings in 3.8 are part of Module node, it's not in the body
74
74
# so we remove it so the following body items have the same indexes on
75
75
# all Python versions
76
- if sys .version_info < (3 , 7 ):
76
+ # This was briefly in 3.7 as well but got reverted in beta 5
77
+ # TODO:
78
+ # We have a complicated sys.version_info if in here to ease testing on
79
+ # various Python 3.7 versions, but we should remove the 3.7 check after
80
+ # 3.7 is released as stable
81
+ if sys .version_info < (3 , 8 ) or
82
+ (3 , 7 ) <= sys .version_info <= (3 , 7 , 0 , 'beta' , 4 ):
77
83
assert isinstance (m .body [0 ], ast .Expr )
78
84
assert isinstance (m .body [0 ].value , ast .Str )
79
85
del m .body [0 ]
@@ -92,7 +98,8 @@ def test_place_initial_imports(self):
92
98
assert isinstance (m .body [3 ], ast .Expr )
93
99
s = """'doc string'\n from __future__ import with_statement"""
94
100
m = rewrite (s )
95
- if sys .version_info < (3 , 7 ):
101
+ if sys .version_info < (3 , 8 ) or
102
+ (3 , 7 ) <= sys .version_info <= (3 , 7 , 0 , 'beta' , 4 ):
96
103
assert isinstance (m .body [0 ], ast .Expr )
97
104
assert isinstance (m .body [0 ].value , ast .Str )
98
105
del m .body [0 ]
@@ -103,7 +110,8 @@ def test_place_initial_imports(self):
103
110
assert imp .col_offset == 0
104
111
s = """'doc string'\n from __future__ import with_statement\n other"""
105
112
m = rewrite (s )
106
- if sys .version_info < (3 , 7 ):
113
+ if sys .version_info < (3 , 8 ) or
114
+ (3 , 7 ) <= sys .version_info <= (3 , 7 , 0 , 'beta' , 4 ):
107
115
assert isinstance (m .body [0 ], ast .Expr )
108
116
assert isinstance (m .body [0 ].value , ast .Str )
109
117
del m .body [0 ]
@@ -124,7 +132,8 @@ def test_place_initial_imports(self):
124
132
def test_dont_rewrite (self ):
125
133
s = """'PYTEST_DONT_REWRITE'\n assert 14"""
126
134
m = rewrite (s )
127
- if sys .version_info < (3 , 7 ):
135
+ if sys .version_info < (3 , 8 ) or
136
+ (3 , 7 ) <= sys .version_info <= (3 , 7 , 0 , 'beta' , 4 ):
128
137
assert len (m .body ) == 2
129
138
assert isinstance (m .body [0 ], ast .Expr )
130
139
assert isinstance (m .body [0 ].value , ast .Str )
0 commit comments