config_file_handler module

Description

This module contains all the code for searching for, caching, and implementing config files.

pytest_helper.config_file_handler.get_config(calling_mod, calling_mod_dir, disable=False)[source]

Return the configuration corresponding to the module calling_mod. Return an empty dict if no config is found. Caches its values in the namespace of the modules (in the pytest-helper data dict). Also caches config files based on their pathnames. If nothing is found in the cache, it looks for the file and reads it in if possible. If disable is set for a module then get_config will always return an empty config dict for the given module and skip searching for the file.

pytest_helper.config_file_handler.get_config_file_pathname(calling_mod_dir)[source]

Get the full pathname of the configuration file, returning None if nothing was found. Go up the directory tree starting at calling_mod_dir, taking the first file found with an allowed name. If no package are encountered by the top-level root directory, return None.

pytest_helper.config_file_handler.get_config_value(config_key, default, calling_mod, calling_mod_dir)[source]

Return the config value from the config file corresponding to the key config_key. Return the value default if no config value is set. This is called in the main functions to get defaults.

pytest_helper.config_file_handler.get_importing_module_filename(level=2)[source]

Run this during the initialization of a module to return the absolute pathname of the module that it is being imported from.

pytest_helper.config_file_handler.read_and_eval_config_file(filename)[source]

Return a dict of dicts containing a dict of parameter arguments for each section of the config file, with the evaluated value.