MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_code

Method test_code

test/test_code.py:44–60  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

42 self.assertRaises(AttributeError, set_c)
43
44 def test_code(self):
45 a_string = "hello world"
46 a_code = Code("hello world")
47 self.assertTrue(a_code.startswith("hello"))
48 self.assertTrue(a_code.endswith("world"))
49 self.assertIsInstance(a_code, Code)
50 self.assertNotIsInstance(a_string, Code)
51 self.assertIsNone(a_code.scope)
52 with_scope = Code("hello world", {"my_var": 5})
53 self.assertEqual({"my_var": 5}, with_scope.scope)
54 empty_scope = Code("hello world", {})
55 self.assertEqual({}, empty_scope.scope)
56 another_scope = Code(with_scope, {"new_var": 42})
57 self.assertEqual(str(with_scope), str(another_scope))
58 self.assertEqual({"new_var": 42, "my_var": 5}, another_scope.scope)
59 # No error.
60 Code("héllø world¡")
61
62 def test_repr(self):
63 c = Code("hello world", {})

Callers

nothing calls this directly

Calls 1

CodeClass · 0.90

Tested by

no test coverage detected