diff --git a/core/config.py b/core/config.py index a800e912c..3d636decb 100644 --- a/core/config.py +++ b/core/config.py @@ -443,10 +443,10 @@ class Config(BaseConfig): :return: """ - try: - return getattr(self, key)(default=default) - except AttributeError: - return + if default is not None: + return self._get_value_from_key(key)(default) + else: + return self._get_value_from_key(key)() async def set(self, key, value): # Notice to future developers: diff --git a/tests/conftest.py b/tests/conftest.py index 20efc7a69..97f3b4fe1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,7 +18,7 @@ def json_driver(tmpdir_factory): return driver -@pytest.fixture(scope="module") +@pytest.fixture() def config(json_driver): return Config( cog_name="PyTest", @@ -26,7 +26,7 @@ def config(json_driver): driver_spawn=json_driver) -@pytest.fixture(scope="module") +@pytest.fixture() def config_fr(json_driver): """ Mocked config object with force_register enabled. diff --git a/tests/core/test_config.py b/tests/core/test_config.py index ff1c24256..6c59fbd4c 100644 --- a/tests/core/test_config.py +++ b/tests/core/test_config.py @@ -145,3 +145,18 @@ async def test_set_channel_no_register(config, empty_channel): await config.channel(empty_channel).set("no_register", True) assert config.channel(empty_channel).no_register() is True #endregion + + +# region Getting Values +def test_get_func_w_reg(config): + config.register_global( + thing=True + ) + assert config.get("thing") is True + assert config.get("thing", False) is False + + +def test_get_func_wo_reg(config): + assert config.get("thing") is None + assert config.get("thing", True) is True +# endregion