def test_registers_functions(self): locals_ = {} transform( Mock(locals=locals_), constants=set(), functions=set(["c", "d"])) for value in ("c", "d"): self.assertIn(value, locals_) self.assertEqual(len(locals_[value]), 1) self.assertIsInstance(locals_[value][0], scoped_nodes.FunctionDef) self.assertEqual(locals_[value][0].name, value)
def test_registers_functions(self): locals_ = {} transform(Mock(locals=locals_), constants=set(), functions=set(["c", "d"])) for value in ("c", "d"): self.assertIn(value, locals_) self.assertEqual(len(locals_[value]), 1) self.assertIsInstance(locals_[value][0], scoped_nodes.FunctionDef) self.assertEqual(locals_[value][0].name, value)
def test_registers_constants(self): locals_ = {} transform( Mock(locals=locals_), constants=set(["a", "b"]), functions=set()) for value in ("a", "b"): self.assertIn(value, locals_) self.assertEqual(len(locals_[value]), 1) try: self.assertIsInstance(locals_[value][0], scoped_nodes.ClassDef) except AttributeError: self.assertEqual(sys.version_info[0:2], (2, 6)) self.assertEqual(locals_[value][0].name, value)
def test_registers_constants(self): locals_ = {} transform(Mock(locals=locals_), constants=set(["a", "b"]), functions=set()) for value in ("a", "b"): self.assertIn(value, locals_) self.assertEqual(len(locals_[value]), 1) try: self.assertIsInstance(locals_[value][0], scoped_nodes.ClassDef) except AttributeError: self.assertEqual(sys.version_info[0:2], (2, 6)) self.assertEqual(locals_[value][0].name, value)
def test_functions_type(self): with self.assertRaises(AssertionError): transform(Mock(locals={}), constants=set(), functions=None)