Commit d819a441 authored by Dylan Trotter's avatar Dylan Trotter Committed by GitHub

Implement future unicode_literals. (#286)

parent 6ec81e81
...@@ -180,7 +180,11 @@ _FUTURE_FEATURES = ( ...@@ -180,7 +180,11 @@ _FUTURE_FEATURES = (
'unicode_literals', 'unicode_literals',
) )
_IMPLEMENTED_FUTURE_FEATURES = ('absolute_import', 'print_function',) _IMPLEMENTED_FUTURE_FEATURES = (
'absolute_import',
'print_function',
'unicode_literals'
)
# These future features are already in the language proper as of 2.6, so # These future features are already in the language proper as of 2.6, so
# importing them via __future__ has no effect. # importing them via __future__ has no effect.
......
...@@ -279,8 +279,6 @@ class MakeFutureFeaturesTest(unittest.TestCase): ...@@ -279,8 +279,6 @@ class MakeFutureFeaturesTest(unittest.TestCase):
# by grumpy # by grumpy
('from __future__ import division', ('from __future__ import division',
r'future feature \w+ not yet implemented'), r'future feature \w+ not yet implemented'),
('from __future__ import unicode_literals',
r'future feature \w+ not yet implemented'),
('from __future__ import braces', 'not a chance'), ('from __future__ import braces', 'not a chance'),
('from __future__ import nonexistant_feature', ('from __future__ import nonexistant_feature',
r'future feature \w+ is not defined'), r'future feature \w+ is not defined'),
......
...@@ -303,6 +303,12 @@ class StatementVisitorTest(unittest.TestCase): ...@@ -303,6 +303,12 @@ class StatementVisitorTest(unittest.TestCase):
self.assertRaisesRegexp(util.ImportError, regexp, _ParseAndVisit, self.assertRaisesRegexp(util.ImportError, regexp, _ParseAndVisit,
'foo = bar\nfrom __future__ import print_function') 'foo = bar\nfrom __future__ import print_function')
def testFutureUnicodeLiterals(self):
want = "u'foo'\n"
self.assertEqual((0, want), _GrumpRun(textwrap.dedent("""\
from __future__ import unicode_literals
print repr('foo')""")))
def testImportMember(self): def testImportMember(self):
self.assertEqual((0, "<type 'dict'>\n"), _GrumpRun(textwrap.dedent("""\ self.assertEqual((0, "<type 'dict'>\n"), _GrumpRun(textwrap.dedent("""\
from sys import modules from sys import modules
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment