diff --git a/__main__.py b/__main__.py index 667d9d8..37184c7 100644 --- a/__main__.py +++ b/__main__.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from libmodernize import main if __name__ == '__main__': diff --git a/libmodernize/__init__.py b/libmodernize/__init__.py index b692a3e..4650f81 100644 --- a/libmodernize/__init__.py +++ b/libmodernize/__init__.py @@ -1,4 +1,6 @@ -from lib2to3.fixer_util import FromImport, Newline, find_root +from __future__ import absolute_import + +from lib2to3 import fixer_util from lib2to3.pytree import Leaf, Node from lib2to3.pygram import python_symbols as syms from lib2to3.pgen2 import token @@ -41,7 +43,7 @@ def check_future_import(node): def add_future(node, symbol): - root = find_root(node) + root = fixer_util.find_root(node) for idx, node in enumerate(root.children): if node.type == syms.simple_stmt and \ @@ -56,6 +58,12 @@ def add_future(node, symbol): # already imported return - import_ = FromImport('__future__', [Leaf(token.NAME, symbol, prefix=" ")]) - children = [import_, Newline()] + import_ = fixer_util.FromImport('__future__', + [Leaf(token.NAME, symbol, prefix=" ")]) + children = [import_, fixer_util.Newline()] root.insert_child(idx, Node(syms.simple_stmt, children)) + + +def touch_import(package, name, node): + add_future(node, 'absolute_import') + fixer_util.touch_import(package, name, node) diff --git a/libmodernize/fixes/__init__.py b/libmodernize/fixes/__init__.py index ce98fda..e022ba9 100644 --- a/libmodernize/fixes/__init__.py +++ b/libmodernize/fixes/__init__.py @@ -8,7 +8,6 @@ 'lib2to3.fixes.fix_funcattrs', 'lib2to3.fixes.fix_has_key', 'lib2to3.fixes.fix_idioms', - 'lib2to3.fixes.fix_import', 'lib2to3.fixes.fix_long', 'lib2to3.fixes.fix_methodattrs', 'lib2to3.fixes.fix_ne', diff --git a/libmodernize/fixes/fix_basestring.py b/libmodernize/fixes/fix_basestring.py index 1f82587..a5d1600 100644 --- a/libmodernize/fixes/fix_basestring.py +++ b/libmodernize/fixes/fix_basestring.py @@ -1,5 +1,8 @@ +from __future__ import absolute_import + from lib2to3 import fixer_base -from lib2to3.fixer_util import touch_import, Name +from lib2to3 import fixer_util +import libmodernize class FixBasestring(fixer_base.BaseFix): @@ -7,5 +10,5 @@ class FixBasestring(fixer_base.BaseFix): PATTERN = """'basestring'""" def transform(self, node, results): - touch_import(None, u'six', node) - return Name(u'six.string_types', prefix=node.prefix) + libmodernize.touch_import(None, u'six', node) + return fixer_util.Name(u'six.string_types', prefix=node.prefix) diff --git a/libmodernize/fixes/fix_dict_six.py b/libmodernize/fixes/fix_dict_six.py index f47198f..6e85710 100644 --- a/libmodernize/fixes/fix_dict_six.py +++ b/libmodernize/fixes/fix_dict_six.py @@ -1,10 +1,12 @@ """Fixer for iterkeys() -> six.iterkeys(), and similarly for iteritems and itervalues.""" +from __future__ import absolute_import # Local imports from lib2to3 import fixer_base from lib2to3 import fixer_util from lib2to3 import patcomp from lib2to3.fixes import fix_dict +import libmodernize class FixDictSix(fix_dict.FixDict): @@ -13,7 +15,7 @@ def transform_iter(self, method_name, node, base): """Call six.iteritems() and friends.""" if method_name.startswith(u'view'): method_name = u'iter' + method_name[4:] - fixer_util.touch_import(None, u'six', node) + libmodernize.touch_import(None, u'six', node) new_node = [n.clone() for n in base] new_node[0].prefix = u'' name = fixer_util.Name(u'six.' + method_name, prefix=node.prefix) diff --git a/libmodernize/fixes/fix_file.py b/libmodernize/fixes/fix_file.py index 7783cfc..6bcdc9c 100644 --- a/libmodernize/fixes/fix_file.py +++ b/libmodernize/fixes/fix_file.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from lib2to3 import fixer_base from lib2to3.fixer_util import Name @@ -6,7 +8,7 @@ class FixFile(fixer_base.BaseFix): BM_compatible = True order = 'pre' - + PATTERN = """ power< name='file' trailer< diff --git a/libmodernize/fixes/fix_filter.py b/libmodernize/fixes/fix_filter.py index 138ac3a..320f589 100644 --- a/libmodernize/fixes/fix_filter.py +++ b/libmodernize/fixes/fix_filter.py @@ -1,8 +1,10 @@ # Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. +from __future__ import absolute_import from lib2to3 import fixer_base -from lib2to3.fixer_util import Call, Name, touch_import, in_special_context +from lib2to3.fixer_util import Call, Name, in_special_context +from libmodernize import touch_import class FixFilter(fixer_base.ConditionalFix): diff --git a/libmodernize/fixes/fix_import.py b/libmodernize/fixes/fix_import.py new file mode 100644 index 0000000..a6e1d37 --- /dev/null +++ b/libmodernize/fixes/fix_import.py @@ -0,0 +1,18 @@ +from __future__ import absolute_import + +from lib2to3.fixes import fix_import +import libmodernize + + +class FixImport(fix_import.FixImport): + + # Make sure this runs before any other fixer to guarantee that any other + # added absolute_import doesn't block this fixer's execution. + run_order = 1 + + def transform(self, node, results): + results = super(FixImport, self).transform(node, results) + if results is None: + return + libmodernize.add_future(node, 'absolute_import') + return results diff --git a/libmodernize/fixes/fix_input_six.py b/libmodernize/fixes/fix_input_six.py index a4d6e19..6048595 100644 --- a/libmodernize/fixes/fix_input_six.py +++ b/libmodernize/fixes/fix_input_six.py @@ -7,9 +7,11 @@ # # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014 Python Software Foundation. All rights reserved. +from __future__ import absolute_import from lib2to3 import fixer_base -from lib2to3.fixer_util import Call, Name, touch_import +from lib2to3.fixer_util import Call, Name +from libmodernize import touch_import class FixInputSix(fixer_base.ConditionalFix): diff --git a/libmodernize/fixes/fix_map.py b/libmodernize/fixes/fix_map.py index 60ebd6b..29f8aa9 100644 --- a/libmodernize/fixes/fix_map.py +++ b/libmodernize/fixes/fix_map.py @@ -1,8 +1,10 @@ # Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. +from __future__ import absolute_import from lib2to3 import fixer_base -from lib2to3.fixer_util import Call, Name, touch_import, in_special_context +from lib2to3.fixer_util import Call, Name, in_special_context +from libmodernize import touch_import class FixMap(fixer_base.ConditionalFix): diff --git a/libmodernize/fixes/fix_metaclass.py b/libmodernize/fixes/fix_metaclass.py index a617fa6..505bb26 100644 --- a/libmodernize/fixes/fix_metaclass.py +++ b/libmodernize/fixes/fix_metaclass.py @@ -25,12 +25,14 @@ # 2011, 2012, 2013 Python Software Foundation. All rights reserved. # Author: Jack Diederich, Daniel Neuhäuser +from __future__ import absolute_import # Local imports from lib2to3 import fixer_base from lib2to3.pygram import token -from lib2to3.fixer_util import Name, syms, Node, Leaf, touch_import, Call, \ +from lib2to3.fixer_util import Name, syms, Node, Leaf, Call, \ String, Comma, parenthesize +from libmodernize import touch_import def has_metaclass(parent): diff --git a/libmodernize/fixes/fix_next.py b/libmodernize/fixes/fix_next.py index 36b347d..309f82d 100644 --- a/libmodernize/fixes/fix_next.py +++ b/libmodernize/fixes/fix_next.py @@ -1,8 +1,9 @@ """Fixer for it.next() -> advance_iterator(it)""" +from __future__ import absolute_import # Local imports from lib2to3 import fixer_base -from lib2to3.fixer_util import touch_import, Name, Call +from lib2to3.fixer_util import Name, Call bind_warning = "Calls to builtin next() possibly shadowed by global binding" diff --git a/libmodernize/fixes/fix_open.py b/libmodernize/fixes/fix_open.py index e36c1b7..63322f1 100644 --- a/libmodernize/fixes/fix_open.py +++ b/libmodernize/fixes/fix_open.py @@ -1,5 +1,7 @@ +from __future__ import absolute_import + from lib2to3 import fixer_base -from lib2to3.fixer_util import touch_import +import libmodernize class FixOpen(fixer_base.ConditionalFix): @@ -15,4 +17,4 @@ class FixOpen(fixer_base.ConditionalFix): def transform(self, node, results): if self.should_skip(node): return - touch_import(u'io', u'open', node) + libmodernize.touch_import(u'io', u'open', node) diff --git a/libmodernize/fixes/fix_print.py b/libmodernize/fixes/fix_print.py index 45554de..8e845eb 100644 --- a/libmodernize/fixes/fix_print.py +++ b/libmodernize/fixes/fix_print.py @@ -13,6 +13,7 @@ No changes are applied if print_function is imported from __future__ """ +from __future__ import absolute_import # Local imports from lib2to3 import patcomp, pytree, fixer_base diff --git a/libmodernize/fixes/fix_raise.py b/libmodernize/fixes/fix_raise.py index 505c584..bf76399 100644 --- a/libmodernize/fixes/fix_raise.py +++ b/libmodernize/fixes/fix_raise.py @@ -18,6 +18,7 @@ this. """ # Author: Collin Winter, Armin Ronacher +from __future__ import absolute_import # Local imports from lib2to3 import pytree, fixer_base diff --git a/libmodernize/fixes/fix_raise_six.py b/libmodernize/fixes/fix_raise_six.py index 1279a79..92e052c 100644 --- a/libmodernize/fixes/fix_raise_six.py +++ b/libmodernize/fixes/fix_raise_six.py @@ -4,10 +4,12 @@ """ # Author : Markus Unterwaditzer +from __future__ import absolute_import # Local imports from lib2to3 import fixer_base -from lib2to3.fixer_util import Name, Call, Comma, touch_import +from lib2to3.fixer_util import Name, Call, Comma +from libmodernize import touch_import class FixRaiseSix(fixer_base.BaseFix): diff --git a/libmodernize/fixes/fix_unicode.py b/libmodernize/fixes/fix_unicode.py index 1d63eea..987ea3e 100644 --- a/libmodernize/fixes/fix_unicode.py +++ b/libmodernize/fixes/fix_unicode.py @@ -1,7 +1,10 @@ +from __future__ import absolute_import + import re from lib2to3.pgen2 import token from lib2to3 import fixer_base -from lib2to3.fixer_util import touch_import, Name, Call +from lib2to3.fixer_util import Name, Call +from libmodernize import touch_import _mapping = {u"unichr" : u"chr", u"unicode" : u"str"} _literal_re = re.compile(u"[uU][rR]?[\\'\\\"]") diff --git a/libmodernize/fixes/fix_unicode_future.py b/libmodernize/fixes/fix_unicode_future.py index 0a456c6..3c6a799 100644 --- a/libmodernize/fixes/fix_unicode_future.py +++ b/libmodernize/fixes/fix_unicode_future.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from lib2to3.fixes import fix_unicode from libmodernize import add_future diff --git a/libmodernize/fixes/fix_unicode_type.py b/libmodernize/fixes/fix_unicode_type.py index f7113e9..89bec8c 100644 --- a/libmodernize/fixes/fix_unicode_type.py +++ b/libmodernize/fixes/fix_unicode_type.py @@ -1,11 +1,13 @@ -from lib2to3 import fixer_base -from lib2to3.fixer_util import touch_import, Name +from __future__ import absolute_import +from lib2to3 import fixer_base +from lib2to3 import fixer_util +import libmodernize class FixUnicodeType(fixer_base.BaseFix): BM_compatible = True PATTERN = """'unicode'""" def transform(self, node, results): - touch_import(None, u'six', node) - return Name(u'six.text_type', prefix=node.prefix) + libmodernize.touch_import(None, u'six', node) + return fixer_util.Name(u'six.text_type', prefix=node.prefix) diff --git a/libmodernize/fixes/fix_xrange_six.py b/libmodernize/fixes/fix_xrange_six.py index f41d028..263f39d 100644 --- a/libmodernize/fixes/fix_xrange_six.py +++ b/libmodernize/fixes/fix_xrange_six.py @@ -1,9 +1,11 @@ # Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. +from __future__ import absolute_import from lib2to3 import fixer_base -from lib2to3.fixer_util import Call, Name, touch_import +from lib2to3.fixer_util import Call, Name from lib2to3.fixes import fix_xrange +from libmodernize import touch_import class FixXrangeSix(fixer_base.ConditionalFix, fix_xrange.FixXrange): diff --git a/libmodernize/fixes/fix_zip.py b/libmodernize/fixes/fix_zip.py index b0609db..c443611 100644 --- a/libmodernize/fixes/fix_zip.py +++ b/libmodernize/fixes/fix_zip.py @@ -1,8 +1,10 @@ # Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. +from __future__ import absolute_import from lib2to3 import fixer_base -from lib2to3.fixer_util import Name, Call, touch_import, in_special_context +from lib2to3.fixer_util import Name, Call, in_special_context +from libmodernize import touch_import class FixZip(fixer_base.ConditionalFix): diff --git a/libmodernize/main.py b/libmodernize/main.py index 7a35ba2..de7c953 100644 --- a/libmodernize/main.py +++ b/libmodernize/main.py @@ -1,4 +1,4 @@ -from __future__ import print_function +from __future__ import absolute_import, print_function import sys import logging diff --git a/modernize.py b/modernize.py index 8fab86d..c548366 100644 --- a/modernize.py +++ b/modernize.py @@ -1,2 +1,4 @@ +from __future__ import absolute_import + from libmodernize.main import main main() diff --git a/tests/test_fix_basestring.py b/tests/test_fix_basestring.py index 544fa5e..51796ab 100644 --- a/tests/test_fix_basestring.py +++ b/tests/test_fix_basestring.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input BASESTRING = ("""\ isinstance(x, basestring) """, """\ +from __future__ import absolute_import import six isinstance(x, six.string_types) """) diff --git a/tests/test_fix_dict_six.py b/tests/test_fix_dict_six.py index 855853e..971b0cb 100644 --- a/tests/test_fix_dict_six.py +++ b/tests/test_fix_dict_six.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from utils import check_on_input @@ -6,6 +8,7 @@ DICT_ITER = ("""\ x.iter{type}() """, """\ +from __future__ import absolute_import import six six.iter{type}(x) """) @@ -13,6 +16,7 @@ DICT_VIEW = ("""\ x.view{type}() """, """\ +from __future__ import absolute_import import six six.iter{type}(x) """) diff --git a/tests/test_fix_file.py b/tests/test_fix_file.py index eda0b6d..3b62279 100644 --- a/tests/test_fix_file.py +++ b/tests/test_fix_file.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from utils import check_on_input diff --git a/tests/test_fix_filter.py b/tests/test_fix_filter.py index 87dc88e..7216e32 100644 --- a/tests/test_fix_filter.py +++ b/tests/test_fix_filter.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input FILTER_CALL = ("""\ filter(None, [1]) """, """\ +from __future__ import absolute_import from six.moves import filter list(filter(None, [1])) """) @@ -30,6 +33,7 @@ for a in filter(None, [1]): pass """, """\ +from __future__ import absolute_import from six.moves import filter for a in filter(None, [1]): pass diff --git a/tests/test_fix_input_six.py b/tests/test_fix_input_six.py index 9ce8ce1..a3a0950 100644 --- a/tests/test_fix_input_six.py +++ b/tests/test_fix_input_six.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input INPUT = ("""\ input() """, """\ +from __future__ import absolute_import from six.moves import input eval(input()) """) @@ -11,6 +14,7 @@ INPUT_ARGS = ("""\ input('hello') """, """\ +from __future__ import absolute_import from six.moves import input eval(input('hello')) """) @@ -18,6 +22,7 @@ RAW_INPUT = ("""\ raw_input() """, """\ +from __future__ import absolute_import from six.moves import input input() """) @@ -25,6 +30,7 @@ RAW_INPUT_TRAILER = ("""\ raw_input()[0] """, """\ +from __future__ import absolute_import from six.moves import input input()[0] """) @@ -33,6 +39,7 @@ raw_input() input() """, """\ +from __future__ import absolute_import from six.moves import input input() eval(input()) diff --git a/tests/test_fix_map.py b/tests/test_fix_map.py index 76eac82..8868853 100644 --- a/tests/test_fix_map.py +++ b/tests/test_fix_map.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input MAP_2_ARGS = ("""\ map(x, [1]) """, """\ +from __future__ import absolute_import from six.moves import map list(map(x, [1])) """) @@ -11,6 +14,7 @@ MAP_3_ARGS = ("""\ map(x, [1], [2]) """, """\ +from __future__ import absolute_import from six.moves import map list(map(x, [1], [2])) """) @@ -18,6 +22,7 @@ MAP_4_ARGS = ("""\ map(x, [1], [2], [3]) """, """\ +from __future__ import absolute_import from six.moves import map list(map(x, [1], [2], [3])) """) @@ -44,6 +49,7 @@ for a in map(x, [1]): pass """, """\ +from __future__ import absolute_import from six.moves import map for a in map(x, [1]): pass diff --git a/tests/test_fix_metaclass.py b/tests/test_fix_metaclass.py index dfdb9fe..0cdb230 100644 --- a/tests/test_fix_metaclass.py +++ b/tests/test_fix_metaclass.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from utils import check_on_input @@ -5,6 +7,7 @@ class Foo: __metaclass__ = Meta """, """\ +from __future__ import absolute_import import six class Foo(six.with_metaclass(Meta)): pass @@ -14,6 +17,7 @@ class Foo(six.with_metaclass(Meta)): class Foo(): __metaclass__ = Meta """, """\ +from __future__ import absolute_import import six class Foo(six.with_metaclass(Meta)): pass @@ -23,6 +27,7 @@ class Foo(six.with_metaclass(Meta)): class Foo(Bar): __metaclass__ = Meta """, """\ +from __future__ import absolute_import import six class Foo(six.with_metaclass(Meta, Bar)): pass @@ -32,6 +37,7 @@ class Foo(six.with_metaclass(Meta, Bar)): class Foo(Bar, Spam): __metaclass__ = Meta """, """\ +from __future__ import absolute_import import six class Foo(six.with_metaclass(Meta, Bar, Spam)): pass @@ -40,6 +46,7 @@ class Foo(six.with_metaclass(Meta, Bar, Spam)): METACLASS_ONE_LINER = ("""\ class Foo: __metaclass__ = Meta """, """\ +from __future__ import absolute_import import six class Foo(six.with_metaclass(Meta)): pass """) @@ -49,6 +56,7 @@ class Foo(Bar): __metaclass__ = Meta; a = 12 b = 64 """, """\ +from __future__ import absolute_import import six class Foo(six.with_metaclass(Meta, Bar)): a = 12 diff --git a/tests/test_fix_next.py b/tests/test_fix_next.py index 8c95516..b87183c 100644 --- a/tests/test_fix_next.py +++ b/tests/test_fix_next.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from utils import check_on_input diff --git a/tests/test_fix_open.py b/tests/test_fix_open.py index f95f541..8822040 100644 --- a/tests/test_fix_open.py +++ b/tests/test_fix_open.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input OPEN = ("""\ open('some/path') """, """\ +from __future__ import absolute_import from io import open open('some/path') """) diff --git a/tests/test_fix_print.py b/tests/test_fix_print.py index 0fa5ddf..f2ededa 100644 --- a/tests/test_fix_print.py +++ b/tests/test_fix_print.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from utils import check_on_input diff --git a/tests/test_fix_raise.py b/tests/test_fix_raise.py index 6b9593e..41b3a42 100644 --- a/tests/test_fix_raise.py +++ b/tests/test_fix_raise.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from utils import check_on_input diff --git a/tests/test_fix_unicode.py b/tests/test_fix_unicode.py index 52e6c7e..32fd5dc 100644 --- a/tests/test_fix_unicode.py +++ b/tests/test_fix_unicode.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from utils import check_on_input UNICODE_LITERALS = """\ @@ -8,6 +10,7 @@ """ UNICODE_LITERALS_six = """\ +from __future__ import absolute_import import six a = six.u('') b = six.u("\\u2041") diff --git a/tests/test_fix_unicode_type.py b/tests/test_fix_unicode_type.py index 7bbbeb1..058880b 100644 --- a/tests/test_fix_unicode_type.py +++ b/tests/test_fix_unicode_type.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input UNICODE_TYPE_REF = ("""\ isinstance(u'str', unicode) """, """\ +from __future__ import absolute_import import six isinstance(u'str', six.text_type) """) @@ -11,6 +14,7 @@ UNICODE_TYPE_CALL = ("""\ unicode(x) """, """\ +from __future__ import absolute_import import six six.text_type(x) """) diff --git a/tests/test_fix_xrange_six.py b/tests/test_fix_xrange_six.py index 611d258..55601c9 100644 --- a/tests/test_fix_xrange_six.py +++ b/tests/test_fix_xrange_six.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input RANGE = ("""\ x = range(1) """, """\ +from __future__ import absolute_import from six.moves import range x = list(range(1)) """) @@ -11,6 +14,7 @@ XRANGE = ("""\ xrange(1) """, """\ +from __future__ import absolute_import from six.moves import range range(1) """) @@ -19,6 +23,7 @@ x = xrange(1) y = range(1) """, """\ +from __future__ import absolute_import from six.moves import range x = range(1) y = list(range(1)) diff --git a/tests/test_fix_zip.py b/tests/test_fix_zip.py index dbcb2c0..65cb09c 100644 --- a/tests/test_fix_zip.py +++ b/tests/test_fix_zip.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input ZIP_CALL_NO_ARGS = ("""\ zip() """, """\ +from __future__ import absolute_import from six.moves import zip list(zip()) """) @@ -11,6 +14,7 @@ ZIP_CALL_1_ARG = ("""\ zip(x) """, """\ +from __future__ import absolute_import from six.moves import zip list(zip(x)) """) @@ -19,6 +23,7 @@ zip(x, y) zip(w, z) """, """\ +from __future__ import absolute_import from six.moves import zip list(zip(x, y)) list(zip(w, z)) @@ -27,6 +32,7 @@ ZIP_CALL_STAR_ARGS = ("""\ zip(*args) """, """\ +from __future__ import absolute_import from six.moves import zip list(zip(*args)) """) @@ -41,6 +47,7 @@ for a in zip(x): pass """, """\ +from __future__ import absolute_import from six.moves import zip for a in zip(x): pass diff --git a/tests/test_fixes.py b/tests/test_fixes.py index c7ca80f..addc637 100644 --- a/tests/test_fixes.py +++ b/tests/test_fixes.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + from lib2to3 import refactor import sys diff --git a/tests/test_future_behaviour.py b/tests/test_future_behaviour.py index 98384a8..2a9be86 100644 --- a/tests/test_future_behaviour.py +++ b/tests/test_future_behaviour.py @@ -1,5 +1,5 @@ - # Tests for problem with multiple futures added to single file +from __future__ import absolute_import import tempfile import os diff --git a/tests/test_raise_six.py b/tests/test_raise_six.py index 73a3c60..57b14a4 100644 --- a/tests/test_raise_six.py +++ b/tests/test_raise_six.py @@ -1,9 +1,12 @@ +from __future__ import absolute_import + from utils import check_on_input RAISE_TRACEBACK = ("""\ raise Exception, value, traceback """, """\ +from __future__ import absolute_import import six six.reraise(Exception, value, traceback) """) diff --git a/tests/utils.py b/tests/utils.py index 035298b..18544e4 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import os.path import tempfile import shutil @@ -36,4 +38,4 @@ def _check(this_input_content, which_check): _check(input_content, "output check failed") _check(expected_content, "idempotence check failed") finally: - shutil.rmtree(tmpdirname) \ No newline at end of file + shutil.rmtree(tmpdirname)