parent
6ee35631af
commit
144729f9ee
@ -298,7 +298,7 @@ def getfutureimports(entity):
|
|||||||
Returns:
|
Returns:
|
||||||
A tuple of future strings
|
A tuple of future strings
|
||||||
"""
|
"""
|
||||||
if not (tf_inspect.isfunction(entity) or tf_inspect.ismethod(entity)):
|
if not tf_inspect.isfunction(entity):
|
||||||
return tuple()
|
return tuple()
|
||||||
return tuple(sorted(name for name, value in entity.__globals__.items()
|
return tuple(sorted(name for name, value in entity.__globals__.items()
|
||||||
if getattr(value, '__module__', None) == '__future__'))
|
if getattr(value, '__module__', None) == '__future__'))
|
||||||
|
@ -415,18 +415,12 @@ class InspectUtilsTest(test.TestCase):
|
|||||||
self.assertTrue(inspect_utils.isbuiltin(zip))
|
self.assertTrue(inspect_utils.isbuiltin(zip))
|
||||||
self.assertFalse(inspect_utils.isbuiltin(function_decorator))
|
self.assertFalse(inspect_utils.isbuiltin(function_decorator))
|
||||||
|
|
||||||
def test_getfutureimports_functions(self):
|
def test_getfutureimports_simple_case(self):
|
||||||
expected_imports = ('absolute_import', 'division', 'print_function',
|
expected_imports = ('absolute_import', 'division', 'print_function',
|
||||||
'with_statement')
|
'with_statement')
|
||||||
self.assertEqual(inspect_utils.getfutureimports(future_import_module.f),
|
self.assertEqual(inspect_utils.getfutureimports(future_import_module.f),
|
||||||
expected_imports)
|
expected_imports)
|
||||||
|
|
||||||
def test_getfutureimports_methods(self):
|
|
||||||
expected_imports = ('absolute_import', 'division', 'print_function',
|
|
||||||
'with_statement')
|
|
||||||
self.assertEqual(inspect_utils.getfutureimports(future_import_module.Foo.f),
|
|
||||||
expected_imports)
|
|
||||||
|
|
||||||
def test_super_wrapper_for_dynamic_attrs(self):
|
def test_super_wrapper_for_dynamic_attrs(self):
|
||||||
|
|
||||||
a = object()
|
a = object()
|
||||||
|
@ -24,9 +24,3 @@ from __future__ import with_statement
|
|||||||
|
|
||||||
def f():
|
def f():
|
||||||
print('foo')
|
print('foo')
|
||||||
|
|
||||||
|
|
||||||
class Foo(object):
|
|
||||||
|
|
||||||
def f(self):
|
|
||||||
print('foo')
|
|
||||||
|
Loading…
Reference in New Issue
Block a user