def test__replace_dict_val_to_const(self): dict_val = {'a': {'b': 100}, 'c': 200, 'd': [100]} const_dict = const.ConstDict(dict_val=dict_val) assert_true(isinstance(const_dict['a'], const.ConstDict)) assert_equal(const_dict['a']['b'], 100) assert_equal(const_dict['c'], 200) assert_true(isinstance(const_dict['d'], const.ConstList)) assert_equal(const_dict['d'][0], 100)
def test_update(self): const_dict = const.ConstDict(dict_val={'a': 100}) try: const_dict.update({'b': 200}) except const.ConstantError: return err_msg = 'Error nor raised when update dict values.' raise AssertionError(err_msg)
def test_pop(self): const_dict = const.ConstDict(dict_val={'a': 100}) try: _ = const_dict.pop('a') except const.ConstantError: return err_msg = 'Error not raised when pop method is called.' raise AssertionError(err_msg)
def test_clear(self): const_dict = const.ConstDict(dict_val={'a': 100}) try: const_dict.clear() except const.ConstantError: return err_msg = 'Error not raised when clear dict values.' raise AssertionError(err_msg)
def test___delitem__(self): const_dict = const.ConstDict(dict_val={'a': 300}) try: del const_dict['a'] except const.ConstantError: return err_msg = 'Error not raised when delete dict value.' raise AssertionError(err_msg)
def test___setitem__(self): const_dict = const.ConstDict(dict_val={'a': 100}) try: const_dict['a'] = 200 except const.ConstantError: return err_msg = 'Update of dict value is not raise error.' raise AssertionError(err_msg)
def test___init__(self): args = [100] assert_class_constructor_will_raise_error( target_class=const.ConstDict, error_class=ValueError, args=args) const_dict = const.ConstDict(dict_val={'apple': 100}) assert_false(const_dict._is_constructor) assert_equal( const_dict._original_dict, {'apple': 100}) assert_equal(const_dict['apple'], 100)
def test___repr__(self): const_dict = const.ConstDict(dict_val={'a': 200}) output_str = const_dict.__repr__() assert_equal(output_str, "{'a': 200}")