Module: check_mk
Branch: master
Commit: b930fe1cbc2f82811dcfd8993c0a8c82d5ab43b8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b930fe1cbc2f82…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 27 08:12:28 2017 +0100
Fixed import error in git tests
Change-Id: I7482a597b2b700a114ca770dc694ae1c718a5cdb
---
tests/conftest.py | 1 +
tests/web/classes.py | 3 +++
tests/web/conftest.py | 5 ++++-
tests/web/test_table.py | 7 +++++--
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 4ef06b1..b20c958 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -118,6 +118,7 @@ def _site_id():
site_id = os.environ.get("OMD_SITE")
if site_id == None:
site_id = file(testlib.repo_path() + "/.site").read().strip()
+ putenv("OMD_SITE", site_id)
return site_id
diff --git a/tests/web/classes.py b/tests/web/classes.py
index bd852d7..cb30202 100644
--- a/tests/web/classes.py
+++ b/tests/web/classes.py
@@ -6,6 +6,9 @@
import re
import json
+import sys
+print sys.path
+
# internal imports
from htmllib import html
from htmllib import HTMLGenerator, HTMLCheck_MK
diff --git a/tests/web/conftest.py b/tests/web/conftest.py
index e93e43e..82f8066 100644
--- a/tests/web/conftest.py
+++ b/tests/web/conftest.py
@@ -1,9 +1,12 @@
import __builtin__
import _pytest
+import testlib
import cmk
monkeypatch = _pytest.monkeypatch.MonkeyPatch()
-monkeypatch.syspath_prepend("%s/htdocs" % cmk.paths.web_dir)
+# TODO: Use site path (in integration tests)
+monkeypatch.syspath_prepend("%s/web/htdocs" % (testlib.cmk_path()))
+#monkeypatch.syspath_prepend("/omd/sites/%s/%s/htdocs" %
(os.environ["OMD_SITE"], cmk.paths.web_dir))
# Fake the localization wrapper _(...)
monkeypatch.setattr(__builtin__, "_", lambda x: x, raising=False)
diff --git a/tests/web/test_table.py b/tests/web/test_table.py
index 1728668..3375f4d 100644
--- a/tests/web/test_table.py
+++ b/tests/web/test_table.py
@@ -14,8 +14,6 @@ from tools import compare_html , gentest, compare_and_empty
from classes import DeprecatedRenderer
-import config
-import table
import traceback
def save_user_mock(name, data, user, unlock=False):
pass
@@ -47,21 +45,25 @@ def test_table(monkeypatch, tmpdir):
def test_limit(monkeypatch, tmpdir):
+ import config
monkeypatch.setattr(config, "save_user_file", save_user_mock)
table_test_cubical(False, False, 2, 'html', tmpdir)
def test_sortable(monkeypatch, tmpdir):
+ import config
monkeypatch.setattr(config, "save_user_file", save_user_mock)
table_test_cubical(True, False, None, 'html', tmpdir)
def test_searchable(monkeypatch, tmpdir):
+ import config
monkeypatch.setattr(config, "save_user_file", save_user_mock)
table_test_cubical(False, True, None, 'html', tmpdir)
def test_csv(monkeypatch, tmpdir):
+ import config
monkeypatch.setattr(config, "save_user_file", save_user_mock)
table_test_cubical(False, False, None, 'csv', tmpdir)
@@ -88,6 +90,7 @@ def read_out_csv(text, separator):
def table_test_cubical(sortable, searchable, limit, output_format, tmpdir):
+ import table
html = TableTest()
__builtin__.html = html