forked from LBRYCommunity/lbry-sdk
raised errors directly instead of wrapping with AssertionError
This commit is contained in:
parent
6ed56804b9
commit
0291482abb
2 changed files with 5 additions and 5 deletions
|
@ -353,7 +353,7 @@ class Config(object):
|
||||||
|
|
||||||
def _assert_valid_data_type(self, data_type):
|
def _assert_valid_data_type(self, data_type):
|
||||||
if not data_type in self._data:
|
if not data_type in self._data:
|
||||||
raise AssertionError(KeyError('{} in is not a valid data type'.format(data_type)))
|
raise KeyError('{} in is not a valid data type'.format(data_type))
|
||||||
|
|
||||||
def get_valid_setting_names(self):
|
def get_valid_setting_names(self):
|
||||||
return self._data[TYPE_DEFAULT].keys()
|
return self._data[TYPE_DEFAULT].keys()
|
||||||
|
@ -363,7 +363,7 @@ class Config(object):
|
||||||
|
|
||||||
def _assert_valid_setting(self, name):
|
def _assert_valid_setting(self, name):
|
||||||
if not self._is_valid_setting(name):
|
if not self._is_valid_setting(name):
|
||||||
raise AssertionError(KeyError('{} is not a valid setting'.format(name)))
|
raise KeyError('{} is not a valid setting'.format(name))
|
||||||
|
|
||||||
def _validate_settings(self, data):
|
def _validate_settings(self, data):
|
||||||
invalid_settings = set(data.keys()) - set(self.get_valid_setting_names())
|
invalid_settings = set(data.keys()) - set(self.get_valid_setting_names())
|
||||||
|
@ -373,7 +373,7 @@ class Config(object):
|
||||||
def _assert_editable_setting(self, name):
|
def _assert_editable_setting(self, name):
|
||||||
self._assert_valid_setting(name)
|
self._assert_valid_setting(name)
|
||||||
if name in self._fixed_defaults:
|
if name in self._fixed_defaults:
|
||||||
raise AssertionError(ValueError('{} is not an editable setting'.format(name)))
|
raise ValueError('{} is not an editable setting'.format(name))
|
||||||
|
|
||||||
def _validate_currency(self, currency):
|
def _validate_currency(self, currency):
|
||||||
if currency not in self._fixed_defaults['CURRENCIES'].keys():
|
if currency not in self._fixed_defaults['CURRENCIES'].keys():
|
||||||
|
|
|
@ -39,12 +39,12 @@ class SettingsTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_invalid_setting_raises_exception(self):
|
def test_invalid_setting_raises_exception(self):
|
||||||
settings = self.get_mock_config_instance()
|
settings = self.get_mock_config_instance()
|
||||||
self.assertRaises(AssertionError, settings.set, 'invalid_name', 123)
|
self.assertRaises(KeyError, settings.set, 'invalid_name', 123)
|
||||||
|
|
||||||
def test_invalid_data_type_raises_exception(self):
|
def test_invalid_data_type_raises_exception(self):
|
||||||
settings = self.get_mock_config_instance()
|
settings = self.get_mock_config_instance()
|
||||||
self.assertIsNone(settings.set('test', 123))
|
self.assertIsNone(settings.set('test', 123))
|
||||||
self.assertRaises(AssertionError, settings.set, 'test', 123, ('fake_data_type',))
|
self.assertRaises(KeyError, settings.set, 'test', 123, ('fake_data_type',))
|
||||||
|
|
||||||
def test_setting_precedence(self):
|
def test_setting_precedence(self):
|
||||||
settings = self.get_mock_config_instance()
|
settings = self.get_mock_config_instance()
|
||||||
|
|
Loading…
Reference in a new issue