From 82d685d13ca560d5cd05811641eb4990c9417f64 Mon Sep 17 00:00:00 2001 From: Johannes Date: Wed, 25 Oct 2017 20:47:01 +0200 Subject: [PATCH] changed travis configuration to get py.test to work --- tests/logs/test_log_view.py | 12 +++++------- tests/testlib/__init__.py | 0 tests/testlib/utils.py | 13 +++++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 tests/testlib/__init__.py create mode 100644 tests/testlib/utils.py diff --git a/tests/logs/test_log_view.py b/tests/logs/test_log_view.py index d43a636..7e67920 100644 --- a/tests/logs/test_log_view.py +++ b/tests/logs/test_log_view.py @@ -1,15 +1,13 @@ - from modules.logs import LogView +from tests.testlib import utils class TestLogView(object): def test_get_all_logfiles(self): + LogView._log_directory = utils.get_base_path() + "/logs" - LogView._log_directory = "./logs" - - log_view = LogView() - logfiles = log_view.get_all_logfiles() + logfiles = LogView().get_all_logfiles() - print(logfiles) - assert (len(logfiles) == 2) + # if no log file is found then two square brackets "[]" are returned and string length is 2 + assert (len(logfiles) > 2) diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/testlib/utils.py b/tests/testlib/utils.py new file mode 100644 index 0000000..c35922f --- /dev/null +++ b/tests/testlib/utils.py @@ -0,0 +1,13 @@ +import os + + +def get_base_path(): + marker_file = "run.py" + + current_path = os.getcwd() + + while current_path != 0: + if marker_file in os.listdir(current_path): + return current_path + + current_path = os.path.dirname(os.path.normpath(current_path))