test_builtin.py 582 B

123456789101112131415161718192021222324252627282930
  1. """
  2. Tests for detecting redefinition of builtins.
  3. """
  4. from pyflakes import messages as m
  5. from pyflakes.test.harness import TestCase
  6. class TestBuiltins(TestCase):
  7. def test_builtin_unbound_local(self):
  8. self.flakes('''
  9. def foo():
  10. a = range(1, 10)
  11. range = a
  12. return range
  13. foo()
  14. print(range)
  15. ''', m.UndefinedLocal)
  16. def test_global_shadowing_builtin(self):
  17. self.flakes('''
  18. def f():
  19. global range
  20. range = None
  21. print(range)
  22. f()
  23. ''')