def test_dict_set_does_not_raise(self): example = {'hello': 'world'} ac = bindings.DictAccessor(example, 'i do not exist') bindings.BREAK_ON_ACCESS_FAILURE = True ac.push(True) assert example['i do not exist']
def test_dict_returns_zero_for_no_key(self): example = {'hello': 'world'} ac = bindings.DictAccessor(example, 'i do not exist') bindings.BREAK_ON_ACCESS_FAILURE = False assert ac.pull() == 0
def test_dict_set(self): example = {'hello': 'world'} ac = bindings.DictAccessor(example, 'hello') ac.push('Las Vegas') assert example['hello'] == 'Las Vegas'
def test_dict_raises(self): example = {'hello': 'world'} ac = bindings.DictAccessor(example, 'i do not exist') bindings.BREAK_ON_ACCESS_FAILURE = True self.assertRaises(Exception, ac.pull)
def test_dict_get(self): example = {'hello': 'world'} ac = bindings.DictAccessor(example, 'hello') assert ac.pull() == 'world'