From 0291482abbbf4872aa2fc73315f85abeee59b793 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 11 Oct 2017 07:59:30 +0100 Subject: [PATCH] raised errors directly instead of wrapping with AssertionError --- lbrynet/conf.py | 6 +++--- lbrynet/tests/unit/test_conf.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lbrynet/conf.py b/lbrynet/conf.py index 3a9bfe23b..4b156ad89 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -353,7 +353,7 @@ class Config(object): def _assert_valid_data_type(self, data_type): 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): return self._data[TYPE_DEFAULT].keys() @@ -363,7 +363,7 @@ class Config(object): def _assert_valid_setting(self, 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): invalid_settings = set(data.keys()) - set(self.get_valid_setting_names()) @@ -373,7 +373,7 @@ class Config(object): def _assert_editable_setting(self, name): self._assert_valid_setting(name) 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): if currency not in self._fixed_defaults['CURRENCIES'].keys(): diff --git a/lbrynet/tests/unit/test_conf.py b/lbrynet/tests/unit/test_conf.py index 9d7abca6c..c18ed1f83 100644 --- a/lbrynet/tests/unit/test_conf.py +++ b/lbrynet/tests/unit/test_conf.py @@ -39,12 +39,12 @@ class SettingsTest(unittest.TestCase): def test_invalid_setting_raises_exception(self): 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): settings = self.get_mock_config_instance() 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): settings = self.get_mock_config_instance()