mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-07 21:58:41 +02:00
Convert defaults to their expected types
Fixes problems in reading conf values before the configuration is fully initialized.
This commit is contained in:
44
tests/test_conf.py
Normal file
44
tests/test_conf.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import importlib
|
||||
import unittest
|
||||
|
||||
import osc.conf
|
||||
|
||||
|
||||
class TestConf(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# reset the global `config` in preparation for running the tests
|
||||
importlib.reload(osc.conf)
|
||||
|
||||
def tearDown(self):
|
||||
# reset the global `config` to avoid impacting tests from other classes
|
||||
importlib.reload(osc.conf)
|
||||
|
||||
def test_bool_opts_defaults(self):
|
||||
opts = osc.conf.boolean_opts
|
||||
config = osc.conf.config
|
||||
for opt in opts:
|
||||
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
||||
|
||||
def test_int_opts_defaults(self):
|
||||
opts = osc.conf.integer_opts
|
||||
config = osc.conf.config
|
||||
for opt in opts:
|
||||
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
||||
|
||||
def test_bool_opts(self):
|
||||
osc.conf.get_config()
|
||||
opts = osc.conf.boolean_opts
|
||||
config = osc.conf.config
|
||||
for opt in opts:
|
||||
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
||||
|
||||
def test_int_opts(self):
|
||||
osc.conf.get_config()
|
||||
opts = osc.conf.integer_opts
|
||||
config = osc.conf.config
|
||||
for opt in opts:
|
||||
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Reference in New Issue
Block a user