MCPcopy
hub / github.com/sublimelsp/LSP / test_basics

Method test_basics

tests/test_edit.py:300–315  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

298class TemporarySetting(unittest.TestCase):
299
300 def test_basics(self) -> None:
301 v = sublime.active_window().active_view()
302 s = v.settings()
303 key = "__some_setting_that_should_not_exist__"
304 with temporary_setting(s, key, "hello"):
305 # The value should be modified while in the with-context
306 self.assertEqual(s.get(key), "hello")
307 # The key should be erased once out of the with-context, because it was not present before.
308 self.assertFalse(s.has(key))
309 s.set(key, "hello there")
310 with temporary_setting(s, key, "general kenobi"):
311 # value key should be modified while in the with-context
312 self.assertEqual(s.get(key), "general kenobi")
313 # The key should remain present, and the value should be restored.
314 self.assertEqual(s.get(key), "hello there")
315 s.erase(key)

Callers

nothing calls this directly

Calls 3

temporary_settingFunction · 0.90
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected