diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-03-30 00:33:10 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-03-30 00:33:10 +0100 |
commit | de8b2cb28e722d8a926ba3336b2154914a83cb71 (patch) | |
tree | b7ef4984832e4be40cf611c856ea801784b28a5e | |
parent | ce216122a0115f537269a49f462895a70bef37ff (diff) | |
download | pyflakes-de8b2cb28e722d8a926ba3336b2154914a83cb71.tar.gz |
Restore correct behaviour of __future__ imports
-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): """ |