Skip to content

Commit

Permalink
tests: Fix TestConf to load oscrc from fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Aug 9, 2023
1 parent 79a2a5f commit a581613
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_conf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import importlib
import os
import unittest

import osc.conf


FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "conf_fixtures")


class TestConf(unittest.TestCase):
def setUp(self):
# reset the global `config` in preparation for running the tests
Expand All @@ -13,6 +17,9 @@ def tearDown(self):
# reset the global `config` to avoid impacting tests from other classes
importlib.reload(osc.conf)

def _get_fixtures_dir(self):
return FIXTURES_DIR

def test_bool_opts_defaults(self):
config = osc.conf.config
for opt in osc.conf._boolean_opts:
Expand All @@ -28,15 +35,17 @@ def test_int_opts_defaults(self):
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")

def test_bool_opts(self):
osc.conf.get_config()
oscrc = os.path.join(self._get_fixtures_dir(), "oscrc")
osc.conf.get_config(override_conffile=oscrc, override_no_keyring=True)
config = osc.conf.config
for opt in osc.conf._boolean_opts:
if opt not in config:
continue
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")

def test_int_opts(self):
osc.conf.get_config()
oscrc = os.path.join(self._get_fixtures_dir(), "oscrc")
osc.conf.get_config(override_conffile=oscrc, override_no_keyring=True)
config = osc.conf.config
for opt in osc.conf._integer_opts:
if opt not in config:
Expand Down

0 comments on commit a581613

Please sign in to comment.