From c480047783eeeaad0af4d191d0a534779c2d026a Mon Sep 17 00:00:00 2001 From: Matthias Bach Date: Wed, 3 Jan 2024 01:03:05 +0100 Subject: [PATCH] Avoid tainting the default config When running tests, depending on the order they are discovered, the default_config can become tainted before the test_default_config test is run. This causes this test to fail. Admittedly its likely never an issue when using ntfy as a script. But its in general a good practice not to direcly use mutable objects as default values and less flaky tests are easier to handle. --- ntfy/config.py | 4 ++-- ntfy/default_config.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ntfy/config.py b/ntfy/config.py index 1d2fe39..d94f6b4 100644 --- a/ntfy/config.py +++ b/ntfy/config.py @@ -9,7 +9,7 @@ from ruamel import yaml from . import __version__ -from .default_config import config as default_configuration +from .default_config import get_default_config if yaml.version_info < (0, 15): safe_load = yaml.safe_load @@ -34,7 +34,7 @@ def load_config(config_path=DEFAULT_CONFIG): except IOError as e: if e.errno == errno.ENOENT and config_path == DEFAULT_CONFIG: logger.info('{} not found'.format(config_path)) - config = default_configuration + config = get_default_config() else: logger.error( 'Failed to open {}'.format(config_path), exc_info=True) diff --git a/ntfy/default_config.py b/ntfy/default_config.py index fcd8c8e..80f724a 100644 --- a/ntfy/default_config.py +++ b/ntfy/default_config.py @@ -1 +1,2 @@ -config = {} +def get_default_config(): + return {}