Module: check_mk
Branch: master
Commit: 7fd62d5152d86636c3fb74e17f059550d5d2e895
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7fd62d5152d866…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 22 21:25:32 2018 +0100
Dramatically improved execution check unit tests
The CheckManager fixture is now not pre loading all checks anymore.
The check is now loaded on demand by it's get_check() method.
Change-Id: I81576badb44d8feb79dd4709df19e0143fa82acf
---
tests/checks/conftest.py | 4 +---
tests/testlib/__init__.py | 14 +++++++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/tests/checks/conftest.py b/tests/checks/conftest.py
index 95445e6..73b8e6c 100644
--- a/tests/checks/conftest.py
+++ b/tests/checks/conftest.py
@@ -6,9 +6,7 @@ import testlib
@pytest.fixture(scope="module")
def check_manager():
- manager = testlib.CheckManager()
- manager.load()
- return manager
+ return testlib.CheckManager()
# Automatically refresh caches for each test
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 2a75d08..0a3c924 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -1611,12 +1611,20 @@ def ec(site, web):
# '----------------------------------------------------------------------'
class CheckManager(object):
- # TODO: Make load only needed checks
- def load(self):
+ def load(self, file_names=None):
+ """Load either all check plugins or the given
file_names"""
import cmk_base.checks as checks
- checks.load()
+ import cmk.paths
+
+ if file_names is None:
+ checks.load() # loads all checks
+ else:
+ checks._initialize_data_structures()
+ checks.load_checks(map(lambda f: os.path.join(cmk.paths.checks_dir, f),
file_names))
+
def get_check(self, name):
+ self.load([name.split(".", 1)[0]])
return Check(name)