summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-12-20 01:32:39 +0300
committerSimon Glass <sjg@chromium.org>2023-01-06 05:21:57 +0300
commit1c77598402890ef148c5e114bb5a3a475305ced8 (patch)
treebbe6902436ddffd32909d02e90f0d86b8e44aa46 /tools
parentf9e20e3bff50722d76720a5cd2ce47252bfe553a (diff)
downloadu-boot-1c77598402890ef148c5e114bb5a3a475305ced8.tar.xz
patman: locate test data files via __file__ and pathlib
Previously it would rely on the executing script location, which could break for example when running the tests via 'pytest'. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/patman/func_test.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7b92bc67be..7fa4a00786 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -7,6 +7,7 @@
"""Functional tests for checking that patman behaves correctly"""
import os
+import pathlib
import re
import shutil
import sys
@@ -28,6 +29,10 @@ from patman.test_util import capture_sys_output
import pygit2
from patman import status
+
+TEST_DATA_DIR = pathlib.Path(__file__).parent / 'test/'
+
+
class TestFunctional(unittest.TestCase):
"""Functional tests for checking that patman behaves correctly"""
leb = (b'Lord Edmund Blackadd\xc3\xabr <weasel@blackadder.org>'.
@@ -57,8 +62,7 @@ class TestFunctional(unittest.TestCase):
Returns:
str: Full path to file in the test directory
"""
- return os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
- 'test', fname)
+ return TEST_DATA_DIR / fname
@classmethod
def _get_text(cls, fname):