Module: check_mk
Branch: master
Commit: 1f99559d1ae302367bab753caad93d05ec3e41de
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1f99559d1ae302…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 18 19:26:19 2018 +0200
Cleaned up python warnings found during unit test execution
Change-Id: I4d4e50ebcf24d6ef0823369314159fc9c2fa17e3
---
cmk/gui/bi.py | 4 ++--
tests/conftest.py | 4 ++--
tests/unit/cmk/gui/test_htmllib_OutputFunnel.py | 4 ++--
tests/unit/cmk_base/test_checks.py | 2 --
4 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/cmk/gui/bi.py b/cmk/gui/bi.py
index c1c5d45..87edc8d 100644
--- a/cmk/gui/bi.py
+++ b/cmk/gui/bi.py
@@ -24,13 +24,13 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+import hashlib
import re
import pprint
import time
import os
import marshal
import fcntl
-import md5
import multiprocessing
from contextlib import contextmanager
import traceback
@@ -413,7 +413,7 @@ class JobWorker(multiprocessing.Process):
# Generates a unique id for the given entry
def get_hash(entry):
- return md5.md5(repr(entry) + repr(job)).hexdigest()
+ return hashlib.md5(repr(entry) + repr(job)).hexdigest()
for group in {sg for g in groups for sg in g}: # Flattened groups
new_entries_hash = map(get_hash, new_entries)
diff --git a/tests/conftest.py b/tests/conftest.py
index a24aa53..d24a751 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -57,7 +57,7 @@ def pytest_configure(config):
def pytest_collection_modifyitems(items):
"""Mark collected test types based on their
location"""
for item in items:
- type_marker = item.get_marker("type")
+ type_marker = item.get_closest_marker("type")
if type_marker and type_marker.args:
continue # Do not modify manually set marks
@@ -82,7 +82,7 @@ def pytest_collection_modifyitems(items):
def pytest_runtest_setup(item):
"""Skip tests of unwanted types"""
- test_type = item.get_marker("type")
+ test_type = item.get_closest_marker("type")
if test_type is None:
raise Exception("Test is not TYPE marked: %s" % item)
diff --git a/tests/unit/cmk/gui/test_htmllib_OutputFunnel.py
b/tests/unit/cmk/gui/test_htmllib_OutputFunnel.py
index 96f7032..d7b26ce 100644
--- a/tests/unit/cmk/gui/test_htmllib_OutputFunnel.py
+++ b/tests/unit/cmk/gui/test_htmllib_OutputFunnel.py
@@ -106,7 +106,7 @@ def test_output_funnel_context_raise(html):
assert html.plug_text == [['B']]
raise Exception("Test exception")
except Exception, e:
- assert e.message == "Test exception"
+ assert "%s" % e == "Test exception"
finally:
assert not html.is_plugged()
@@ -124,7 +124,7 @@ def test_output_funnel_try_finally(html):
html.write("finally2\n")
except Exception, e:
html.write("except1\n")
- html.write("%s\n" % e.message)
+ html.write("%s\n" % e)
finally:
html.write("finally1\n")
assert html.written ==
"try1\ntry2\nexcept2\nfinally2\nexcept1\nError\nfinally1\n"
diff --git a/tests/unit/cmk_base/test_checks.py b/tests/unit/cmk_base/test_checks.py
index f273a3b..440c385 100644
--- a/tests/unit/cmk_base/test_checks.py
+++ b/tests/unit/cmk_base/test_checks.py
@@ -1,6 +1,5 @@
import pytest
-import cmk_base.discovery as discovery
import cmk_base.config as config
import cmk_base.check_utils
import cmk_base.check_api as check_api
@@ -67,7 +66,6 @@ def test_do_status_data_inventory_for(monkeypatch, result, ruleset):
############ Management board checks
-(a)pytest.fixture
def _check_plugins():
return {
"tcp_check_mgmt_only" : "mgmt_only",