File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,8 @@ def order_future_lines(code):
44
44
if line .startswith ('from __future__ import ' )]
45
45
46
46
future_line_numbers = [i for i , line in enumerate (lines )
47
- if line .startswith ('from future' )]
47
+ if line .startswith ('from future' )
48
+ or line .startswith ('from past' )]
48
49
49
50
builtins_line_numbers = [i for i , line in enumerate (lines )
50
51
if line .startswith ('from builtins' )]
@@ -56,7 +57,7 @@ def mymax(numbers):
56
57
return max (numbers ) if len (numbers ) > 0 else 0
57
58
58
59
def mymin (numbers ):
59
- return min (numbers ) if len (numbers ) > 0 else 0
60
+ return min (numbers ) if len (numbers ) > 0 else float ( 'inf' )
60
61
61
62
assert mymax (uufuture_line_numbers ) <= mymin (future_line_numbers ), \
62
63
'the __future__ and future imports are out of order'
Original file line number Diff line number Diff line change @@ -104,7 +104,22 @@ def test_encoding_comments_kept_at_top(self):
104
104
from __future__ import print_function
105
105
print('Hello')
106
106
"""
107
- self .convert_check (before , after )
107
+ self .convert_check (before , after , ignore_imports = False )
108
+
109
+ # Issue #121. This fails as of v0.14.1:
110
+ before = u"""
111
+ # -*- coding: utf-8 -*-
112
+ # Author: etc. with some unicode ¿.
113
+ 1 / 2
114
+ """
115
+ after = u"""
116
+ # -*- coding: utf-8 -*-
117
+ # Author: etc. with some unicode ¿.
118
+ from __future__ import division
119
+ from past.utils import old_div
120
+ old_div(1, 2)
121
+ """
122
+ self .convert_check (before , after , ignore_imports = False )
108
123
109
124
def test_shebang_blank_with_future_division_import (self ):
110
125
"""
@@ -435,7 +450,7 @@ def test_source_coding_utf8(self):
435
450
"""
436
451
code = """
437
452
# -*- coding: utf-8 -*-
438
- icons = [u"◐ ", u"◓ ", u"◑ ", u"◒ "]
453
+ icons = [u"â ", u"â ", u"â ", u"â "]
439
454
"""
440
455
self .unchanged (code )
441
456
You can’t perform that action at this time.
0 commit comments