]>
Commit | Line | Data |
---|---|---|
53e6db90 DC |
1 | """ |
2 | Tests for detecting redefinition of builtins. | |
3 | """ | |
4 | from pyflakes import messages as m | |
5 | from pyflakes.test.harness import TestCase | |
6 | ||
7 | ||
8 | class TestBuiltins(TestCase): | |
9 | ||
10 | def test_builtin_unbound_local(self): | |
11 | self.flakes(''' | |
12 | def foo(): | |
13 | a = range(1, 10) | |
14 | range = a | |
15 | return range | |
16 | ||
17 | foo() | |
18 | ||
19 | print(range) | |
20 | ''', m.UndefinedLocal) | |
21 | ||
22 | def test_global_shadowing_builtin(self): | |
23 | self.flakes(''' | |
24 | def f(): | |
25 | global range | |
26 | range = None | |
27 | print(range) | |
28 | ||
29 | f() | |
30 | ''') |