Exemple #1
0
 def test_calling_int_is_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("len(a)")
     visitor.visit(node)
Exemple #2
0
 def test_calling_len_is_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("int('10')")
     visitor.visit(node)
Exemple #3
0
 def test_importing_disallowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("import foo")
     self.assertRaises(CodeNotAllowed, visitor.visit, node)
Exemple #4
0
 def test_function_calls_disallowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("foo()")
     self.assertRaises(CodeNotAllowed, visitor.visit, node)
Exemple #5
0
 def test_calling_int_is_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("len(a)")
     visitor.visit(node)
Exemple #6
0
 def test_index_assignment_disallowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package[0] = 'fwts'")
     self.assertRaises(CodeNotAllowed, visitor.visit, node)
 def test_smoke(self):
     visitor = ResourceNodeVisitor()
     self.assertEqual(visitor.ids_seen_set, set())
     self.assertEqual(visitor.ids_seen_list, [])
Exemple #8
0
 def test_in_expresions_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("'foo' in package.name")
     visitor.visit(node)
Exemple #9
0
 def test_in_expresions_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("'foo' in package.name")
     visitor.visit(node)
Exemple #10
0
 def test_in_expresions_with_list_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name in ['foo', 'bar']")
     visitor.visit(node)
Exemple #11
0
 def test_comparisons_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name == 'foo'")
     visitor.visit(node)
Exemple #12
0
 def test_boolean_ops_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name and package.version")
     visitor.visit(node)
Exemple #13
0
 def test_calling_len_is_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("int('10')")
     visitor.visit(node)
Exemple #14
0
 def test_boolean_ops_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name and package.version")
     visitor.visit(node)
Exemple #15
0
 def test_smoke(self):
     visitor = ResourceNodeVisitor()
     self.assertEqual(visitor.names_seen, set())
Exemple #16
0
 def test_comparisons_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name == 'foo'")
     visitor.visit(node)
Exemple #17
0
 def test_names_seen(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name == 'fwts' and package.version == '1.2'")
     visitor.visit(node)
     self.assertEqual(visitor.names_seen, {'package'})
Exemple #18
0
 def test_in_expresions_with_list_are_allowed(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name in ['foo', 'bar']")
     visitor.visit(node)
Exemple #19
0
 def test_names_seen(self):
     visitor = ResourceNodeVisitor()
     node = ast.parse("package.name == 'fwts' and package.version == '1.2'")
     visitor.visit(node)
     self.assertEqual(visitor.names_seen, {'package'})