From patchwork Mon Oct 26 01:04:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1387361 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JWyKWmCq; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKGqm1xCnz9sTK for ; Mon, 26 Oct 2020 12:06:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20D8C824C7; Mon, 26 Oct 2020 02:05:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JWyKWmCq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 68ECB824A9; Mon, 26 Oct 2020 02:05:11 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 90D6B82485 for ; Mon, 26 Oct 2020 02:05:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id r9so8347986ioo.7 for ; Sun, 25 Oct 2020 18:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C9iCyP4hNNsFPb5BXHG/kuLAH+U3Hla2KsGAs0zmn4M=; b=JWyKWmCqtp8aFghE/I3b8Dddsa9Dw5/DGozMuaTBpLCKyI6eMAm8Dfph4Mi4Pz+Pyn zuRwAXbN/JEn6rJURxIFejhBrrdy6T9ZKdFkBcF2y8m4sSruuEJiLjAA5M+n1Wx7xFM7 TaIkMoTsPvl7hMYT12741tDIZXoeLMWNX/3WQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C9iCyP4hNNsFPb5BXHG/kuLAH+U3Hla2KsGAs0zmn4M=; b=t6SP0bjIKPj1+jFC0WsGLjaC9wyM+U8YKH/znX+rPbBisUQAIJ3ILhx3srGx2r+z3V MZk8dMMJvdad9iPwRIX325/6G6w1Ni68RYHPqS15N3kUoxqxUVuArmm/r50M959GYnZh W+JtvDWzgn8CcrmL4E+OKF7s8pjsw/QxGfnN3qUdVkSlaLziWdPg/4rhuUGnbP5chCpR meSn+wwZsweV/lUW6A9Lo/ouKE7z1DPz4LfnaastnT5wR5nFvOCZYC1tO/kqcrfMlOSn KvXOEOLClTa+Q261wo+YB1iKtkoe4E0GRBgjcKtFKgUg3yOuhtrPNoPbJ+5XGbr08nW5 PkjQ== X-Gm-Message-State: AOAM531DEQ0GH7R7Q9IRKfvHmWYHvmH6sXfKz8mpCjTVprvZ2JV0/Wg/ CMLE7Kcryg/7Y7oj64b0IekT5S1auvI9vyAl X-Google-Smtp-Source: ABdhPJyaV91fBmLQqDrZiAU28regpFX9LXkLv5EqrBgXEMYoIRhZ3JpeyWRTb0VTKE6HOr4rw2KVUg== X-Received: by 2002:a05:6638:d55:: with SMTP id d21mr2284357jak.136.1603674306282; Sun, 25 Oct 2020 18:05:06 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id a6sm5231162ili.11.2020.10.25.18.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 18:05:05 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Doug Anderson , patchwork@lists.ozlabs.org, Simon Glass Subject: [PATCH v2 06/30] patman: Fix remaining pylint3 warnings in func_test Date: Sun, 25 Oct 2020 19:04:18 -0600 Message-Id: <20201026010442.1606893-7-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026010442.1606893-1-sjg@chromium.org> References: <20201026010442.1606893-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This fixes all but the ones about too many variables/statements. Signed-off-by: Simon Glass --- (no changes since v1) tools/patman/func_test.py | 76 +++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 263cb340ef5..b3c3e5796ad 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -4,6 +4,8 @@ # Copyright 2017 Google, Inc # +"""Functional tests for checking that patman behaves correctly""" + import os import re import shutil @@ -27,6 +29,7 @@ except ModuleNotFoundError: class TestFunctional(unittest.TestCase): + """Functional tests for checking that patman behaves correctly""" def setUp(self): self.tmpdir = tempfile.mkdtemp(prefix='patman.') self.gitdir = os.path.join(self.tmpdir, 'git') @@ -36,33 +39,69 @@ class TestFunctional(unittest.TestCase): shutil.rmtree(self.tmpdir) @staticmethod - def GetPath(fname): + def _get_path(fname): + """Get the path to a test file + + Args: + fname (str): Filename to obtain + + 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) @classmethod - def GetText(self, fname): - return open(self.GetPath(fname), encoding='utf-8').read() + def _get_text(cls, fname): + """Read a file as text + + Args: + fname (str): Filename to read + + Returns: + str: Contents of file + """ + return open(cls._get_path(fname), encoding='utf-8').read() @classmethod - def GetPatchName(self, subject): + def _get_patch_name(cls, subject): + """Get the filename of a patch given its subject + + Args: + subject (str): Patch subject + + Returns: + str: Filename for that patch + """ fname = re.sub('[ :]', '-', subject) return fname.replace('--', '-') - def CreatePatchesForTest(self, series): + def _create_patches_for_test(self, series): + """Create patch files for use by tests + + This copies patch files from the test directory as needed by the series + + Args: + series (Series): Series containing commits to convert + + Returns: + tuple: + str: Cover-letter filename, or None if none + fname_list: list of str, each a patch filename + """ cover_fname = None fname_list = [] for i, commit in enumerate(series.commits): - clean_subject = self.GetPatchName(commit.subject) + clean_subject = self._get_patch_name(commit.subject) src_fname = '%04d-%s.patch' % (i + 1, clean_subject[:52]) fname = os.path.join(self.tmpdir, src_fname) - shutil.copy(self.GetPath(src_fname), fname) + shutil.copy(self._get_path(src_fname), fname) fname_list.append(fname) if series.get('cover'): src_fname = '0000-cover-letter.patch' cover_fname = os.path.join(self.tmpdir, src_fname) fname = os.path.join(self.tmpdir, src_fname) - shutil.copy(self.GetPath(src_fname), fname) + shutil.copy(self._get_path(src_fname), fname) return cover_fname, fname_list @@ -137,7 +176,8 @@ class TestFunctional(unittest.TestCase): stefan = b'Stefan Br\xc3\xbcns '.decode('utf-8') rick = 'Richard III ' mel = b'Lord M\xc3\xablchett '.decode('utf-8') - ed = b'Lond Edmund Blackadd\xc3\xabr