def test_context_map_put_and_pop(): map = ContextMap() obj = object() key = map.put(obj) assert isinstance(key, int) eq_(len(map), 1) eq_(map.pop(key), obj) eq_(len(map), 0)
def test_context_map_pop_non_existent_key(): map = ContextMap() key = 1000 try: value = map.pop(key) except KeyError: pass else: raise AssertionError("context map had value %r for key %r" % (value, key))
def __init__(self, profile=None): if profile is None: profile = self.default_profile() self.profile_path = os.path.expanduser(profile) assert os.path.isabs(self.profile_path), \ 'profile path cannot be relative (%s)' % self.profile_path self._setup_profile = set() self.editors = [] self.path_opener = None self.config = Config(self.profile_path) self.context = ContextMap() self.syntax_factory = None state_dir = os.path.join(self.profile_path, const.STATE_DIR) command_history = CommandHistory(state_dir) self.text_commander = TextCommandController(command_history) register_value_transformers()
def test_context_map_pop_with_default(): map = ContextMap() DEF = "default" eq_(map.pop(1000, "default"), "default")
def test_create_context_map(): map = ContextMap() eq_(len(map), 0)