From e4814cf8dc79fc5b7a2f05096f2ba05e8ee44e932eb6102de9a10bcfa05d21b1 Mon Sep 17 00:00:00 2001 From: f4lco Date: Sun, 27 Jan 2019 18:43:56 +0100 Subject: [PATCH] Improve resource loading: do not rely on correct working directory Resources will now be loaded from an absolute path, which was derived from the location of the current module. --- stw_potsdam/config.py | 2 +- tests/test_consistency.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stw_potsdam/config.py b/stw_potsdam/config.py index 8dd3fef..062b0aa 100644 --- a/stw_potsdam/config.py +++ b/stw_potsdam/config.py @@ -9,7 +9,7 @@ from canteen import Canteen def _get_config(filename): config = ConfigParser.SafeConfigParser() - path = os.path.join('stw_potsdam', filename) + path = os.path.join(os.path.dirname(__file__), filename) with io.open(path, encoding='utf-8') as f: config.readfp(f) return config diff --git a/tests/test_consistency.py b/tests/test_consistency.py index e22d326..83e2bc8 100644 --- a/tests/test_consistency.py +++ b/tests/test_consistency.py @@ -9,7 +9,7 @@ from stw_potsdam.config import read_canteen_config def _resource_path(filename): - return os.path.join('tests', 'resources', filename) + return os.path.join(os.path.dirname(__file__), 'resources', filename) def _canteen():