From b08f4790f4190e8bc5eae3f79b5e6a4d3e2a5d9c Mon Sep 17 00:00:00 2001 From: wilhelmagren Date: Sun, 10 Sep 2023 14:11:24 +0200 Subject: [PATCH] chore(tests) load all tests for coverage --- tests/__init__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/__init__.py b/tests/__init__.py index 48cd683..5ced0eb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -24,3 +24,28 @@ File created: 2022-09-10 Last updated: 2023-09-10 """ + +import inspect +import pkgutil +import unittest +import sys +import logging + +log = logging.getLogger(__name__) + +console_handler = logging.StreamHandler(sys.stdout) +console_handler.setLevel(logging.DEBUG) + +formatter = logging.Formatter("[%(asctime)s] [%(name)s] [%(levelname)s\t] %(message)s") + +console_handler.setFormatter(formatter) +log.addHandler(console_handler) + + +def load_tests(loader, suite, pattern): + for imp, modname, _ in pkgutil.walk_packages(__path__): + mod = imp.find_module(modname).load_module(modname) + for test in loader.loadTestsFromModule(mod): + suite.addTests(test) + + return suite