diff --git a/tests/json/test_output.py b/tests/json/test_output.py index 0a796df..92d0e55 100644 --- a/tests/json/test_output.py +++ b/tests/json/test_output.py @@ -9,9 +9,9 @@ import unittest import sys import json import os -from os.path import join, dirname, normpath +from os.path import join from oletools import msodde -from tests.test_utils import OutputCapture +from tests.test_utils import OutputCapture, DATA_BASE_DIR if sys.version_info[0] <= 2: from oletools import olevba @@ -19,16 +19,12 @@ else: from oletools import olevba3 as olevba -# Directory with test data, independent of current working directory -DATA_DIR = normpath(join(dirname(__file__), '..', 'test-data')) - - class TestValidJson(unittest.TestCase): """ Ensure that script output is valid json (if return code is 0) """ def iter_test_files(self): - """ Iterate over all test files in DATA_DIR """ - for dirpath, _, filenames in os.walk(DATA_DIR): + """ Iterate over all test files in DATA_BASE_DIR """ + for dirpath, _, filenames in os.walk(DATA_BASE_DIR): for filename in filenames: yield join(dirpath, filename) diff --git a/tests/msodde_doc/test_basic.py b/tests/msodde_doc/test_basic.py index 2f40aa6..ec6ead8 100644 --- a/tests/msodde_doc/test_basic.py +++ b/tests/msodde_doc/test_basic.py @@ -10,16 +10,12 @@ from __future__ import print_function import unittest from oletools import msodde -from tests.test_utils import OutputCapture +from tests.test_utils import OutputCapture, DATA_BASE_DIR as BASE_DIR import shlex -from os.path import join, dirname, normpath +from os.path import join from traceback import print_exc -# base directory for test input -BASE_DIR = normpath(join(dirname(__file__), '..', 'test-data')) - - class TestReturnCode(unittest.TestCase): def test_valid_doc(self): diff --git a/tests/test_utils/__init__.py b/tests/test_utils/__init__.py index 0c73323..fca8642 100644 --- a/tests/test_utils/__init__.py +++ b/tests/test_utils/__init__.py @@ -1 +1,6 @@ from .output_capture import OutputCapture + +from os.path import dirname, join + +# Directory with test data, independent of current working directory +DATA_BASE_DIR = join(dirname(dirname(__file__)), 'test-data')