tests package

Submodules

tests.test_cache_decorator module

tests.test_cache_decorator.cache()[source]

Fixture to provide a fresh Cache instance.

tests.test_cache_decorator.test_cache_performance(cache)[source]

Test that @cache decorator improves performance by using time.sleep.

tests.test_cache_decorator.test_clear_cache(cache)[source]

Test that clear_cache method empties the cache.

tests.test_cache_decorator.test_get_cached_value_exact_match(cache)[source]

Test that get_cached_value returns the correct result for an exact match.

tests.test_cache_decorator.test_get_cached_value_no_match(cache)[source]

Test that get_cached_value returns None when no match is found.

tests.test_cache_decorator.test_get_cached_value_partial_match_args(cache)[source]

Test that get_cached_value returns results for partial match on args.

tests.test_cache_decorator.test_get_cached_value_partial_match_kwargs(cache)[source]

Test that get_cached_value returns results for partial match on kwargs.

tests.test_log_decorator module

test_func_log_terminal not working

tests.test_log_decorator.cleanup_files()[source]
tests.test_log_decorator.test_func_log_file_json()[source]

Test to check if the json log is working correctly.

tests.test_log_decorator.test_func_log_terminal(caplog)[source]

Test to check if the terminal log is working correctly using caplog.

tests.test_log_decorator.test_get_logfile_path_creates_directory()[source]

Test function to validate the creation of log directory and file path by the LoggerManager’s _get_logfile_path method. Also validates the correct date-based naming of the log file when logfile_name is None.

tests.test_log_decorator.test_log_file_validation()[source]

Test function to check if the terminal logging raise error for using args which don’t impact the code without defining other arguments.

tests.test_log_decorator.test_logger_cleanup()[source]
tests.test_log_decorator.test_logger_manager_creates_log_directory_custom_path()[source]

Test to validate the creation of the log directory at a custom path.

tests.test_log_decorator.test_logging_exceptions()[source]

tests.test_retry_decorator module

test_retry_raise_exception_assertion not working

tests.test_retry_decorator.test_retry_4_times()[source]
tests.test_retry_decorator.test_retry_delay()[source]
tests.test_retry_decorator.test_retry_raise_exception_assertion()[source]
tests.test_retry_decorator.test_retry_type_error()[source]

Test that TypeError is raised when exception_types is not a type or a tuple.

tests.test_retry_decorator.test_retry_value_error()[source]

Test that ValueError is raised when retries < 1 or delay <= 0.

tests.test_run_time_decorator module

tests.test_run_time_decorator.test_decorator_logs_execution_time(caplog)[source]

Module contents

### Testing:

PowerDecos requires pytest. Tests can then be run after installation inside the package folder with:

PowerDecos requires pytest. Tests can then be run after installation:

  • run:`pytest`

  • or run: `poetry run pytest`

  • to get a html coverage review add `--cov-report=html` to the end of `pytest`

NOTE: if it doesn’t work try to go inside the folder and then run the commands