MCPcopy Create free account
hub / github.com/ipython/traitlets / test_context_manager

Method test_context_manager

tests/config/test_loader.py:99–116  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

97 self._check_conf(config)
98
99 def test_context_manager(self):
100 fd, fname = mkstemp(".json", prefix="μnïcø∂e")
101 f = os.fdopen(fd, "w")
102 f.write("{}")
103 f.close()
104
105 cl = JSONFileConfigLoader(fname, log=log)
106
107 value = "context_manager"
108
109 with cl as c:
110 c.MyAttr.value = value
111
112 self.assertEqual(cl.config.MyAttr.value, value)
113
114 # check that another loader does see the change
115 _ = JSONFileConfigLoader(fname, log=log)
116 self.assertEqual(cl.config.MyAttr.value, value)
117
118 def test_json_context_bad_write(self):
119 fd, fname = mkstemp(".json", prefix="μnïcø∂e")

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected