Commit 96b35730 authored by Jason Madden's avatar Jason Madden

More coverage for _config.py [skip ci]

parent 6efd3999
...@@ -49,7 +49,10 @@ class SettingType(type): ...@@ -49,7 +49,10 @@ class SettingType(type):
def getter(self): def getter(self):
return self.settings[setting_name].get() return self.settings[setting_name].get()
def setter(self, value): def setter(self, value): # pragma: no cover
# The setter should never be hit, Config has a
# __setattr__ that would override. But for the sake
# of consistency we provide one.
self.settings[setting_name].set(value) self.settings[setting_name].set(value)
prop = property(getter, setter, doc=new_class.__doc__) prop = property(getter, setter, doc=new_class.__doc__)
...@@ -250,7 +253,7 @@ class ImportableSetting(object): ...@@ -250,7 +253,7 @@ class ImportableSetting(object):
if package_path: if package_path:
try: try:
sys.path.remove(package_path) sys.path.remove(package_path)
except ValueError: except ValueError: # pragma: no cover
pass pass
shortname_map = {} shortname_map = {}
......
...@@ -100,6 +100,10 @@ class TestConfig(unittest.TestCase): ...@@ -100,6 +100,10 @@ class TestConfig(unittest.TestCase):
self.assertEqual(sorted(_config.config.settings), self.assertEqual(sorted(_config.config.settings),
sorted(dir(_config.config))) sorted(dir(_config.config)))
def test_getattr(self):
# Bypass the property that might be set here
self.assertIsNotNone(_config.config.__getattr__('resolver'))
def test__getattr__invalid(self): def test__getattr__invalid(self):
with self.assertRaises(AttributeError): with self.assertRaises(AttributeError):
getattr(_config.config, 'no_such_setting') getattr(_config.config, 'no_such_setting')
...@@ -135,5 +139,9 @@ class TestImportableSetting(unittest.TestCase): ...@@ -135,5 +139,9 @@ class TestImportableSetting(unittest.TestCase):
self.assertEqual(w[0].category, DeprecationWarning) self.assertEqual(w[0].category, DeprecationWarning)
self.assertIn('Absolute paths', str(w[0].message)) self.assertIn('Absolute paths', str(w[0].message))
def test_non_string(self):
i = _config.ImportableSetting()
self.assertIs(i._import(self), self)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment