cfg: Fix test case failure due to incorrect path assumption

When tmpdir fixture is used, the tests run in a separate directory instead of
command execution directory. Any tests that take the current directory and
assume that it contains files will fail. Fix this by taking the path relative to
test module instead.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa committed 2019-10-26 22:07:52 -07:00
1 parent c8eb5bb3ca
commit 83337e4786
1 file changed
+2 -1
+2 -1
View File
@@ -90,7 +90,8 @@ def test_read_primary_config_file():
def test_read_fallback_config_file():
"""Verify that the correct fallback config file is used"""
fallback_root = os.path.realpath('.')
test_dir = os.path.dirname(os.path.realpath(__file__))
fallback_root = os.path.realpath(os.path.join(test_dir, '..', '..'))
fallback_config_file = os.path.join(fallback_root, 'plinth.config')
config_path, root_directory = cfg.get_fallback_config_paths()
cfg.read(config_path, root_directory)