From patchwork Mon Dec 19 14:52:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 1717405 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=B3lzFs16; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NbN4S0zRZz1ydd for ; Tue, 20 Dec 2022 01:53:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 72AF8853DA; Mon, 19 Dec 2022 15:53:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B3lzFs16"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51CF7853D1; Mon, 19 Dec 2022 15:53:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BD08A8504A for ; Mon, 19 Dec 2022 15:53:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.cournoyer@gmail.com Received: by mail-qt1-x82e.google.com with SMTP id c7so8346201qtw.8 for ; Mon, 19 Dec 2022 06:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7A3ccDiFQ6Uug9z1+LoyKkOpRBWFfAt33vgGoZlijks=; b=B3lzFs16DkIR8PWH+U3JpnZuCdAHta1oP6jTv5w8C8SXxYkeLyl26NyvqwlLrIM5KP +Ymxb0tHB7122K6kTB1FX5Gr6Nk0DJ/WNnWlaZGrZAZSNXfdTd0aKcayd8wjtY1KQ9cZ GBlMUEehGXI77e+oXBkvL5RW4vPhz7b+FZ/04GblxnxAAeiAF7+CRvSiiB3cPvB2GKgn vqht2mPryefJX7juD2IYBqXr4iIIdrRpX2ldyF2Q4Nw5V05EoYB99MTpaLyHV1HapFTa 3QY59QLUSF1tWIRBfFtZmdUwZR1vBf2z8vntXGLglh8I1geR5QUHlmSfg1sWPnXPSpWR MTNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7A3ccDiFQ6Uug9z1+LoyKkOpRBWFfAt33vgGoZlijks=; b=wECElptf6QkYspOKjdGGGJTmR3jtkU+dF5j8gXgClyNEXQISASOkSQj0/i1PgL/Kd2 QMiHyxOHTTffnarnIYTYBKTOzZgMgcpqH08P+tjshg0Pg4BL5ZaZkpdjNj6cvf1y1Txp TsYYNIlWcIUf/qnSlYiJUw0fTqgfZd2oFf3kud4LDk69iK3d1C/JBipBVYHo70RZJOHc D0zt/MXkACONxC71i+++2fGW+fJGyTfogwl711qNYxurXkDwKY3Yd0Glkm6GVxWUCeuh 5NC1G72vfNGzAENLfMVGgXcPvUZcjiV86rM/mPOD/t50jgRZctMhjPQegiMcrdM4PSNF 4oWg== X-Gm-Message-State: ANoB5plSHww0eb24C5J/Yc7ZkhvR4+wRKdEQTk7R29CQpcYbDpS9QP4p +IXr2H6Ix/Q5nqjEa4iiTh/2CHmxHcxqDQ== X-Google-Smtp-Source: AA0mqf49CVAUJlej51LQ8bAMJCeRYHNE909ZgmR6BzWnMARkbFzHoqBpUl1mFkQaxrQnmvHJnUi1cg== X-Received: by 2002:a05:622a:1dc4:b0:3a8:1079:b844 with SMTP id bn4-20020a05622a1dc400b003a81079b844mr42635926qtb.46.1671461593265; Mon, 19 Dec 2022 06:53:13 -0800 (PST) Received: from localhost.localdomain (dsl-10-133-202.b2b2c.ca. [72.10.133.202]) by smtp.gmail.com with ESMTPSA id y6-20020a05620a44c600b006fcb4e01345sm7289942qkp.24.2022.12.19.06.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 06:53:12 -0800 (PST) From: Maxim Cournoyer X-Google-Original-From: Maxim Cournoyer To: U-Boot Mailing List Cc: Maxim Cournoyer , Simon Glass Subject: [PATCH v2 2/8] patman: locate test data files via __file__ and pathlib Date: Mon, 19 Dec 2022 09:52:51 -0500 Message-Id: <20221219145258.32046-2-maxim.cournoyer@savoirfairelinux.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219145258.32046-1-maxim.cournoyer@savoirfairelinux.com> References: <20221219145258.32046-1-maxim.cournoyer@savoirfairelinux.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Previously it would rely on the executing script location, which could break for example when running the tests via 'pytest'. Signed-off-by: Maxim Cournoyer Reviewed-by: Simon Glass --- (no changes since v1) tools/patman/func_test.py | 8 ++++++-- 1 file 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 '. @@ -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):