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.
This commit is contained in:
@@ -9,7 +9,7 @@ from canteen import Canteen
|
|||||||
|
|
||||||
def _get_config(filename):
|
def _get_config(filename):
|
||||||
config = ConfigParser.SafeConfigParser()
|
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:
|
with io.open(path, encoding='utf-8') as f:
|
||||||
config.readfp(f)
|
config.readfp(f)
|
||||||
return config
|
return config
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from stw_potsdam.config import read_canteen_config
|
|||||||
|
|
||||||
|
|
||||||
def _resource_path(filename):
|
def _resource_path(filename):
|
||||||
return os.path.join('tests', 'resources', filename)
|
return os.path.join(os.path.dirname(__file__), 'resources', filename)
|
||||||
|
|
||||||
|
|
||||||
def _canteen():
|
def _canteen():
|
||||||
|
|||||||
Reference in New Issue
Block a user