From bff294ed3950ce4cc53178442de304f3fd49ebe4 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 19 May 2020 13:07:19 -0700 Subject: [PATCH] storage: Fix failing path validation unit tests Due to improper python include path. Don't know why the problem surfaced. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Joseph Nuthalapati --- plinth/modules/storage/tests/test_storage.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plinth/modules/storage/tests/test_storage.py b/plinth/modules/storage/tests/test_storage.py index df5fcfda7..4b0716cdf 100644 --- a/plinth/modules/storage/tests/test_storage.py +++ b/plinth/modules/storage/tests/test_storage.py @@ -4,6 +4,7 @@ Test module for storage module operations. """ import os +import pathlib import re import subprocess import tempfile @@ -204,14 +205,14 @@ class TestActions: @staticmethod def call_action(action_command, **kwargs): """Call the action script.""" - current_directory = os.path.dirname(os.path.realpath(__file__)) - action = os.path.join(current_directory, '..', '..', '..', '..', - 'actions', action_command[0]) - action_command[0] = action + test_directory = pathlib.Path(__file__).parent + top_directory = (test_directory / '..' / '..' / '..' / '..').resolve() + action_command[0] = top_directory / 'actions' / action_command[0] kwargs['stdout'] = kwargs.get('stdout', subprocess.DEVNULL) kwargs['stderr'] = kwargs.get('stderr', subprocess.DEVNULL) kwargs['check'] = kwargs.get('check', True) - return subprocess.run(action_command, **kwargs) + env = dict(os.environ, PYTHONPATH=str(top_directory)) + return subprocess.run(action_command, env=env, **kwargs) def check_action(self, action_command): """Return success/failure result of the action command."""