From patchwork Fri Oct 30 03:46:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1390726 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=VataMsSU; 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 4CMpDM5V8Fz9sPB for ; Fri, 30 Oct 2020 14:47:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 999AF8265F; Fri, 30 Oct 2020 04:47:06 +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="VataMsSU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7248282638; Fri, 30 Oct 2020 04:46:55 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 E23BC82585 for ; Fri, 30 Oct 2020 04:46:50 +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-xd43.google.com with SMTP id k21so6119747ioa.9 for ; Thu, 29 Oct 2020 20:46:50 -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=NnIrCIDZEcDcnKGvck+xw+6K0VewgtNefS0t/B/OAFY=; b=VataMsSUXS4Hb/xhtwen+EPbku2CsldIR0aLkYvBuSHcoTSEKP+dG0lon20eHfAQ73 nBZVEISd6Kao22bpNxDFGvqRqKFL5Kwrnw4B61JysXMNmo8mI6bOO7QWykI9YUWiowi2 XhA6F2lNqqw8s9Gy3zTgDEdoEL8SgkvuAB62U= 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=NnIrCIDZEcDcnKGvck+xw+6K0VewgtNefS0t/B/OAFY=; b=tvrvu7ofKTdIUGz6O31Uizedvcr2VNRclxOtT/wayaasBzsmjwflc22554HlsklqBA MGSrwhC2u/KBOqiJinyEMD4J7k0bN9kbWAwmxOY2rEoS0c5o/eD5gM56mk/h74eCA8U6 tW+7B2yA6j38rv6LQzRRNPeBP6nS1ThDOfbNapzMQkIZ8u1BB6Cvrq4Hst+AfkZfKVvs 1UIfb3s0fs5kMi1dDL++FwT6PWpA/JSqa3hT5zB2RVY03i1UvXEpS2PHWZynsU9N/tEN x3jUzpl95f7C4vQqCyf7s6GUYXlbs22RPwOIbkzaQ12vawxXJeqFwqlqCLUsyGmeTHtV OuyA== X-Gm-Message-State: AOAM532gJ6P0C/F5wFRQw5rJ/3KQ3SAL5tAsa6j3qBoz7jvIvznPKCLf g3J4FzqPiG/2Bf66GE2rn3OqxwYA3aWmO4Md X-Google-Smtp-Source: ABdhPJyiVLLmfPyUQLri0z8pWN7XajylKkX6keqYoR0Wrqb75/Rswzb/H+1KqllKoX57fO+poy8Tfg== X-Received: by 2002:a5d:96c1:: with SMTP id r1mr398610iol.147.1604029609728; Thu, 29 Oct 2020 20:46:49 -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 n28sm4858693ila.52.2020.10.29.20.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 20:46:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: patchwork@lists.ozlabs.org, Doug Anderson , Tom Rini , Simon Glass Subject: [PATCH v3 05/29] patman: Use capture_sys_output() consistently Date: Thu, 29 Oct 2020 21:46:14 -0600 Message-Id: <20201030034638.2858999-6-sjg@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201030034638.2858999-1-sjg@chromium.org> References: <20201030034638.2858999-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 One test still uses its own function for capturing output. Modify it to use the standard one in test_util Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) tools/patman/func_test.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 7fffe649974..263cb340ef5 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -4,7 +4,6 @@ # Copyright 2017 Google, Inc # -import contextlib import os import re import shutil @@ -12,8 +11,6 @@ import sys import tempfile import unittest -from io import StringIO - from patman import control from patman import gitutil from patman import patchstream @@ -29,19 +26,6 @@ except ModuleNotFoundError: HAVE_PYGIT2 = False -@contextlib.contextmanager -def capture(): - oldout, olderr = sys.stdout, sys.stderr - try: - out = [StringIO(), StringIO()] - sys.stdout, sys.stderr = out - yield out - finally: - sys.stdout, sys.stderr = oldout, olderr - out[0] = out[0].getvalue() - out[1] = out[1].getvalue() - - class TestFunctional(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp(prefix='patman.') @@ -169,7 +153,7 @@ class TestFunctional(unittest.TestCase): text = self.GetText('test01.txt') series = patchstream.GetMetaDataForTest(text) cover_fname, args = self.CreatePatchesForTest(series) - with capture() as out: + with capture_sys_output() as out: patchstream.FixPatches(series, args) if cover_fname and series.get('cover'): patchstream.InsertCoverLetter(cover_fname, series, count) @@ -184,7 +168,7 @@ class TestFunctional(unittest.TestCase): cc_lines = open(cc_file, encoding='utf-8').read().splitlines() os.remove(cc_file) - lines = out[0].splitlines() + lines = out[0].getvalue().splitlines() self.assertEqual('Cleaned %s patches' % len(series.commits), lines[0]) self.assertEqual('Change log missing for v2', lines[1]) self.assertEqual('Change log missing for v3', lines[2])