diff options
-rw-r--r-- | pyflakes/checker.py | 4 | ||||
-rw-r--r-- | pyflakes/test/test_doctests.py | 3 | ||||
-rw-r--r-- | pyflakes/test/test_imports.py | 9 |
3 files changed, 14 insertions, 2 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py index 8388fbc..e4b5b1e 100644 --- a/pyflakes/checker.py +++ b/pyflakes/checker.py @@ -827,8 +827,8 @@ class Checker(object): if not self.futuresAllowed: self.report(messages.LateFutureImport, node, [n.name for n in node.names]) - return - self.futuresAllowed = False + else: + self.futuresAllowed = False for alias in node.names: if alias.name == '*': diff --git a/pyflakes/test/test_doctests.py b/pyflakes/test/test_doctests.py index 86054e2..3a74304 100644 --- a/pyflakes/test/test_doctests.py +++ b/pyflakes/test/test_doctests.py @@ -230,6 +230,9 @@ class TestImports(_DoctestMixin, TestImports): def test_futureImport(self): """XXX This test can't work in a doctest""" + def test_futureImportUsed(self): + """XXX This test can't work in a doctest""" + class TestUndefinedNames(_DoctestMixin, TestUndefinedNames): diff --git a/pyflakes/test/test_imports.py b/pyflakes/test/test_imports.py index bc8548f..164f182 100644 --- a/pyflakes/test/test_imports.py +++ b/pyflakes/test/test_imports.py @@ -693,6 +693,15 @@ class Test(TestCase): bar ''', m.LateFutureImport) + def test_futureImportUsed(self): + """__future__ is special, but names are injected in the namespace.""" + self.flakes(''' + from __future__ import division + from __future__ import print_function + + assert print_function is not division + ''') + class TestSpecialAll(TestCase): """ |