]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
patman: locate test data files via __file__ and pathlib
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>
Mon, 19 Dec 2022 22:32:39 +0000 (17:32 -0500)
committerSimon Glass <sjg@chromium.org>
Fri, 6 Jan 2023 02:21:57 +0000 (19:21 -0700)
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>
tools/patman/func_test.py

index 7b92bc67be1eff37134d58fe72fccfd8c992d8dd..7fa4a00786c5794f5ed3ada63cff1b9397377843 100644 (file)
@@ -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):