Example #1
0
 def test_operator_rhs(self):
     used, unknown = xg.NameChecker({}).check(
         self.build_ast('"test" + right'))
     self.assertEqual(unknown, set(['right']))
Example #2
0
 def test_slice_arg(self):
     used, unknown = xg.NameChecker({}).check(
         self.build_ast('"test"[1:int(_)]'))
     self.assertEqual(unknown, set(['int', '_']))
Example #3
0
 def test_operator_lhs(self):
     used, unknown = xg.NameChecker({}).check(self.build_ast('left * 2'))
     self.assertEqual(unknown, set(['left']))
Example #4
0
 def test_method_arg_const(self):
     used, unknown = xg.NameChecker({}).check(
         self.build_ast('os.stat("foo")'))
     self.assertEqual(unknown, set(['os']))
Example #5
0
 def test_slice(self):
     used, unknown = xg.NameChecker({}).check(self.build_ast('_[:5]'))
     self.assertEqual(unknown, set(['_']))
Example #6
0
 def test_method_arg_name(self):
     used, unknown = xg.NameChecker({}).check(self.build_ast('os.stat(_)'))
     self.assertEqual(unknown, set(['os', '_']))
Example #7
0
 def test_attribute_not_name(self):
     used, unknown = xg.NameChecker({}).check(
         self.build_ast('open(_).name'))
     self.assertEqual(unknown, set(['open', '_']))
Example #8
0
 def test_underscore_is_name(self):
     used, unknown = xg.NameChecker({}).check(self.build_ast('int(_)'))
     self.assertEqual(unknown, set(['int', '_']))
Example #9
0
 def test_names_mix(self):
     names = {'foo': None}
     used, unknown = xg.NameChecker(names).check(self.build_ast('foo(bar)'))
     self.assertEqual(used, set(names))
     self.assertEqual(unknown, set(['bar']))
Example #10
0
 def test_all_names_unknown(self):
     used, unknown = xg.NameChecker({}).check(self.build_ast('foo(bar)'))
     self.assertEqual(used, set())
     self.assertEqual(unknown, set(['foo', 'bar']))