def test_code(self): a_string = "hello world" a_code = Code("hello world") self.assertTrue(a_code.startswith("hello")) self.assertTrue(a_code.endswith("world")) self.assertTrue(isinstance(a_code, Code)) self.assertFalse(isinstance(a_string, Code)) self.assertIsNone(a_code.scope) with_scope = Code('hello world', {'my_var': 5}) self.assertEqual({'my_var': 5}, with_scope.scope) empty_scope = Code('hello world', {}) self.assertEqual({}, empty_scope.scope) another_scope = Code(with_scope, {'new_var': 42}) self.assertEqual(str(with_scope), str(another_scope)) self.assertEqual({'new_var': 42, 'my_var': 5}, another_scope.scope) # No error. Code(u'héllø world¡')
def test_code(self): a_string = "hello world" a_code = Code("hello world") self.assert_(a_code.startswith("hello")) self.assert_(a_code.endswith("world")) self.assert_(isinstance(a_code, Code)) self.assertFalse(isinstance(a_string, Code)) self.assertEqual(a_code.scope, {}) a_code.scope["my_var"] = 5 self.assertEqual(a_code.scope, {"my_var": 5})
def test_code(self): a_string = "hello world" a_code = Code("hello world") self.assertTrue(a_code.startswith("hello")) self.assertTrue(a_code.endswith("world")) self.assertTrue(isinstance(a_code, Code)) self.assertFalse(isinstance(a_string, Code)) self.assertEqual(a_code.scope, {}) a_code.scope["my_var"] = 5 self.assertEqual(a_code.scope, {"my_var": 5})