Module: check_mk
Branch: master
Commit: 4ee56925af4c54de9f1881fca0cfede34ee793ed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4ee56925af4c54…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Sep 5 15:14:44 2018 +0200
generictests: Fix mystical bug, and prevent silently not testing anything
Change-Id: I830501eb52aad0216a0d6b69206ff9195de622d7
---
tests/unit/checks/generictests/checkhandler.py | 4 ++--
tests/unit/checks/generictests/run.py | 8 +++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/unit/checks/generictests/checkhandler.py
b/tests/unit/checks/generictests/checkhandler.py
index 7eb4c93..03792c2 100644
--- a/tests/unit/checks/generictests/checkhandler.py
+++ b/tests/unit/checks/generictests/checkhandler.py
@@ -1,12 +1,12 @@
import cmk_base.config as config
import cmk_base.check_api as check_api
-
+import copy
class CheckHandler(object):
"""Collect the info on all checks"""
def __init__(self):
config.load_all_checks(check_api.get_check_api_context)
- self.info = config.check_info
+ self.info = copy.deepcopy(config.check_info)
self.cache = {}
def get_applicables(self, checkname):
diff --git a/tests/unit/checks/generictests/run.py
b/tests/unit/checks/generictests/run.py
index 1fb24e4..eb6d44e 100644
--- a/tests/unit/checks/generictests/run.py
+++ b/tests/unit/checks/generictests/run.py
@@ -78,7 +78,6 @@ def parse(check_manager, dataset):# .
If the .parsed attribute is present, it is compared to the result.
"""
print("parse: %r" % dataset.checkname)
-
info = getattr(dataset, 'info', None)
parsed_expected = getattr(dataset, 'parsed', None)
@@ -180,8 +179,10 @@ def check_listed_result(check, list_entry, info_arg, immu):# .
def run(check_manager, dataset, write=False):
"""Run all possible tests on 'dataset'"""
print("START: %r" % dataset)
- immu = Immutables()
+ checklist = checkhandler.get_applicables(dataset.checkname)
+ assert checklist
+ immu = Immutables()
# test the parse function
parsed = parse(check_manager, dataset)
immu.register(parsed, 'parsed')
@@ -189,8 +190,9 @@ def run(check_manager, dataset, write=False):
# get the expected check results, if present
checks_expected = getattr(dataset, 'checks', {})
+
# LOOP OVER ALL (SUB)CHECKS
- for sname in checkhandler.get_applicables(dataset.checkname):
+ for sname in checklist:
subcheck = (sname + '.').split('.')[1]
check = check_manager.get_check(sname)