From patchwork Mon Mar 16 15:47:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1995 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773676118; bh=gmSid7X3VTLZ3noCzD8ggLK0oFPmDqriZKT/bqW6+5U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Vnl/bAFhwURaGWvTz0NNCqg9uOJqVkznbMgnh3836BFWncOI8JHfq53ZyX7jSP2tW OE6cZn8GOEgactTaWMYly9dM5MAERQ+t/5AVbBP5rTwHhrtSzqgGr3LHwlKrJnkC7/ O0CMmeoGa9oPUiKrlGD+7hz3I5JqfaGVCfzAh/ElHJhuxicRj2UebOMtif1qHXFdVj iHE6QK8rv/2ru3tAQRZ95Eq7O6HQgmcIcV2ibHQOzmvGFfTtNEPYWQXhU9cVc9VA5p 3eJn6RrTlDwwVvZz2+D+v720WMjQrpljSimtB1HY+j8tN3egzssMHgE6790UQnJHZp pQuz6mYAk1GBw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E7CF56A081 for ; Mon, 16 Mar 2026 09:48:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 68FcTqrxp5k4 for ; Mon, 16 Mar 2026 09:48:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773676117; bh=gmSid7X3VTLZ3noCzD8ggLK0oFPmDqriZKT/bqW6+5U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uy5gCci4GtB3EN53FJn9NLZ661M0fhYoSt2GNGywKyei6awmflVjKh+cLt4RHnEHJ PAzp498G3Rzzo9fC3EMjgqZFZ+kLhRatowRiTP1KFCBfob86HGlr05dGZAPAlLFCk8 k5EzWit36MDrQQNKBu1Uw65IaSR1X27eTzn/5C3acINMIWqmxFlZp3yBCswuIjEKIp dvH15cVlTiGX+rplYmdXTocRUcWC3SMUX0J53pKKkqe0FZKBi3AG9fHx+DvBotxD/D PNEq1NizG98dFpW5rnpqWBx68OYJIK06pVtyHiJBWrjyZ89Efw7m0rul2C42Jr+uCi nS3E5I5DERZoQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A499C6A08C for ; Mon, 16 Mar 2026 09:48:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773676114; bh=B0uJKHdac2oSTRlCgHlMj+YoKb7fBZZXG/cgq4BmAwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMrXR+37g3wFUS9KFcLlWb8qmq1q6LAiyhl/+penGgP6ffcoBMYsOhCXAucZshA06 uId3lU3LXiZ8UyKBuI1ELeZ5NYmRAx4XinNuRCoOyTo2XNwjrJ1RBEKls/vYV3hvAw GyCwqPWYYNY0rIpnElecjaPpkWC2+qr4xqyxnWi8aAop/7UTgDgNd19vtma5tCW8XQ hR9lYpkIU2jdNoJE6zoC6StkarQWqX2I7x8Wk1h3B5g2jU6EQqCefAtzyhchmBBeGY pO/dO8Pimx8fC+CDE16TjKc5p1EkBQ3/QLeJ9IXaxnNBkbQbWzO+fvY523MNJZ7x4m W3p5+WvEtya6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5E1E66A07E; Mon, 16 Mar 2026 09:48:34 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id lsz_19wUAUyf; Mon, 16 Mar 2026 09:48:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773676112; bh=6JzfB+E23VwW4H94cDO3uo36UnKNr/tDYdayXEm6g50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VO3hCKhTr0Uz0r16T41iFkFm+iwsnP74dPsOHkEeT7FA4/rdKmxnm6YczARnZLMA/ V49rJZcQBITSmFOQsvPa/2ce/jw6C0+cJ05XzmYiyjYBPsUvjxp++sYg5YiVQ2UxZ1 Zhwe9QMIUPo6IzDN2A68LfpeNFSsiUgsvusSGMCsOahHoHkM95Dp6con2WGsXUocwM dDrkpdqcwEoLooE0BYCSkzavqjDyDzzHuNAtIZWIMDboq7FQfD31pz2cgDU9j9Fdmd 0myyVKpMYvmdPlMfKXORqYzU+OmtQwguyzKIk/q8Qd1UEttfLPTLEFDGhG4lqyYQO7 UNfg3VLNKz++A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 90E426A081; Mon, 16 Mar 2026 09:48:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 16 Mar 2026 09:47:09 -0600 Message-ID: <20260316154733.1587261-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260316154733.1587261-1-sjg@u-boot.org> References: <20260316154733.1587261-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FUKXTGECZCJMRHKCXCWMQSJSYPQ6524X X-Message-ID-Hash: FUKXTGECZCJMRHKCXCWMQSJSYPQ6524X X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/20] buildman: Fix pylint warnings in test_builder.py List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Remove unused OUTCOME_WARNING import, prefix unused mock arguments with underscore, and replace unnecessary lambda wrappers around datetime with direct references. Signed-off-by: Simon Glass --- tools/buildman/test_builder.py | 61 ++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/tools/buildman/test_builder.py b/tools/buildman/test_builder.py index ec1e0301a6e..70a8b365f2a 100644 --- a/tools/buildman/test_builder.py +++ b/tools/buildman/test_builder.py @@ -4,6 +4,8 @@ """Unit tests for builder.py""" +# pylint: disable=W0212 + from datetime import datetime import os import shutil @@ -12,7 +14,7 @@ from unittest import mock from buildman import builder from buildman import builderthread -from buildman.outcome import (DisplayOptions, OUTCOME_OK, OUTCOME_WARNING, +from buildman.outcome import (DisplayOptions, OUTCOME_OK, OUTCOME_ERROR, OUTCOME_UNKNOWN) from buildman.resulthandler import ResultHandler from u_boot_pylib import gitutil @@ -183,7 +185,7 @@ class TestPrepareThread(unittest.TestCase): @mock.patch.object(gitutil, 'fetch') @mock.patch.object(os.path, 'isdir', return_value=True) @mock.patch.object(builderthread, 'mkdir') - def test_existing_clone(self, mock_mkdir, mock_isdir, mock_fetch): + def test_existing_clone(self, _mock_mkdir, _mock_isdir, mock_fetch): """Test with existing git clone (fetches updates)""" terminal.get_print_test_lines() # Clear self.builder._prepare_thread(0, 'clone') @@ -196,7 +198,7 @@ class TestPrepareThread(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=True) @mock.patch.object(os.path, 'isdir', return_value=False) @mock.patch.object(builderthread, 'mkdir') - def test_existing_worktree(self, mock_mkdir, mock_isdir, mock_isfile): + def test_existing_worktree(self, _mock_mkdir, _mock_isdir, _mock_isfile): """Test with existing worktree (no action needed)""" terminal.get_print_test_lines() # Clear self.builder._prepare_thread(0, 'worktree') @@ -209,8 +211,8 @@ class TestPrepareThread(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=False) @mock.patch.object(os.path, 'isdir', return_value=False) @mock.patch.object(builderthread, 'mkdir') - def test_invalid_git_dir(self, mock_mkdir, mock_isdir, mock_isfile, - mock_exists): + def test_invalid_git_dir(self, _mock_mkdir, _mock_isdir, _mock_isfile, + _mock_exists): """Test with git_dir that exists but is neither file nor directory""" with self.assertRaises(ValueError) as ctx: self.builder._prepare_thread(0, 'clone') @@ -222,8 +224,8 @@ class TestPrepareThread(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=False) @mock.patch.object(os.path, 'isdir', return_value=False) @mock.patch.object(builderthread, 'mkdir') - def test_create_worktree(self, mock_mkdir, mock_isdir, mock_isfile, - mock_exists, mock_add_worktree): + def test_create_worktree(self, _mock_mkdir, _mock_isdir, _mock_isfile, + _mock_exists, mock_add_worktree): """Test creating a new worktree""" terminal.get_print_test_lines() # Clear self.builder._prepare_thread(0, 'worktree') @@ -238,8 +240,8 @@ class TestPrepareThread(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=False) @mock.patch.object(os.path, 'isdir', return_value=False) @mock.patch.object(builderthread, 'mkdir') - def test_create_clone(self, mock_mkdir, mock_isdir, mock_isfile, - mock_exists, mock_clone): + def test_create_clone(self, _mock_mkdir, _mock_isdir, _mock_isfile, + _mock_exists, mock_clone): """Test creating a new clone""" terminal.get_print_test_lines() # Clear self.builder._prepare_thread(0, 'clone') @@ -254,8 +256,8 @@ class TestPrepareThread(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=False) @mock.patch.object(os.path, 'isdir', return_value=False) @mock.patch.object(builderthread, 'mkdir') - def test_create_clone_with_true(self, mock_mkdir, mock_isdir, mock_isfile, - mock_exists, mock_clone): + def test_create_clone_with_true(self, _mock_mkdir, _mock_isdir, + _mock_isfile, _mock_exists, mock_clone): """Test creating a clone when setup_git=True""" terminal.get_print_test_lines() # Clear self.builder._prepare_thread(0, True) @@ -266,8 +268,8 @@ class TestPrepareThread(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=False) @mock.patch.object(os.path, 'isdir', return_value=False) @mock.patch.object(builderthread, 'mkdir') - def test_invalid_setup_git(self, mock_mkdir, mock_isdir, mock_isfile, - mock_exists): + def test_invalid_setup_git(self, _mock_mkdir, _mock_isdir, _mock_isfile, + _mock_exists): """Test with invalid setup_git value""" with self.assertRaises(ValueError) as ctx: self.builder._prepare_thread(0, 'invalid') @@ -304,9 +306,10 @@ class TestPrepareWorkingSpace(unittest.TestCase): @mock.patch.object(builder.Builder, '_prepare_thread') @mock.patch.object(gitutil, 'prune_worktrees') - @mock.patch.object(gitutil, 'check_worktree_is_available', return_value=True) + @mock.patch.object(gitutil, 'check_worktree_is_available', + return_value=True) @mock.patch.object(builderthread, 'mkdir') - def test_worktree_available(self, mock_mkdir, mock_check_worktree, + def test_worktree_available(self, _mock_mkdir, mock_check_worktree, mock_prune, mock_prepare_thread): """Test when worktree is available""" self.builder._prepare_working_space(3, True) @@ -320,9 +323,10 @@ class TestPrepareWorkingSpace(unittest.TestCase): mock_prepare_thread.assert_any_call(2, 'worktree') @mock.patch.object(builder.Builder, '_prepare_thread') - @mock.patch.object(gitutil, 'check_worktree_is_available', return_value=False) + @mock.patch.object(gitutil, 'check_worktree_is_available', + return_value=False) @mock.patch.object(builderthread, 'mkdir') - def test_worktree_not_available(self, mock_mkdir, mock_check_worktree, + def test_worktree_not_available(self, _mock_mkdir, mock_check_worktree, mock_prepare_thread): """Test when worktree is not available (falls back to clone)""" self.builder._prepare_working_space(2, True) @@ -335,7 +339,7 @@ class TestPrepareWorkingSpace(unittest.TestCase): @mock.patch.object(builder.Builder, '_prepare_thread') @mock.patch.object(builderthread, 'mkdir') - def test_zero_threads(self, mock_mkdir, mock_prepare_thread): + def test_zero_threads(self, _mock_mkdir, mock_prepare_thread): """Test with max_threads=0 (should still prepare 1 thread)""" self.builder._prepare_working_space(0, False) @@ -345,7 +349,7 @@ class TestPrepareWorkingSpace(unittest.TestCase): @mock.patch.object(builder.Builder, '_prepare_thread') @mock.patch.object(builderthread, 'mkdir') - def test_no_git_dir(self, mock_mkdir, mock_prepare_thread): + def test_no_git_dir(self, _mock_mkdir, mock_prepare_thread): """Test with no git_dir set""" self.builder.git_dir = None self.builder._prepare_working_space(2, True) @@ -394,7 +398,7 @@ class TestShowNotBuilt(unittest.TestCase): self.assertEqual(len(lines), 0) def test_some_boards_unknown(self): - """Test when some boards have OUTCOME_UNKNOWN (e.g. missing toolchain)""" + """Test when some boards have OUTCOME_UNKNOWN""" board_selected = {'board1': None, 'board2': None, 'board3': None} board_dict = { 'board1': self._make_outcome(OUTCOME_OK), @@ -430,7 +434,7 @@ class TestShowNotBuilt(unittest.TestCase): self.assertIn('board2', lines[0].text) def test_build_error_not_counted(self): - """Test that build errors (not toolchain) are not counted as 'not built'""" + """Test that build errors are not counted as 'not built'""" board_selected = {'board1': None, 'board2': None} board_dict = { 'board1': self._make_outcome(OUTCOME_OK), @@ -450,8 +454,9 @@ class TestShowNotBuilt(unittest.TestCase): board_selected = {'board1': None, 'board2': None, 'board3': None} board_dict = { 'board1': self._make_outcome(OUTCOME_OK), - 'board2': self._make_outcome(OUTCOME_ERROR, - ['Tool chain error for arm: not found']), + 'board2': self._make_outcome( + OUTCOME_ERROR, + ['Tool chain error for arm: not found']), 'board3': self._make_outcome(OUTCOME_ERROR, ['error: some build error']), } @@ -468,7 +473,7 @@ class TestShowNotBuilt(unittest.TestCase): self.assertNotIn('board3', lines[0].text) def test_board_not_in_dict(self): - """Test that boards missing from board_dict are counted as 'not built'""" + """Test boards missing from board_dict count as 'not built'""" board_selected = {'board1': None, 'board2': None, 'board3': None} board_dict = { 'board1': self._make_outcome(OUTCOME_OK), @@ -487,7 +492,7 @@ class TestShowNotBuilt(unittest.TestCase): class TestPrepareOutputSpace(unittest.TestCase): - """Tests for Builder._prepare_output_space() and _get_output_space_removals()""" + """Tests for _prepare_output_space() and _get_output_space_removals()""" def setUp(self): """Set up test fixtures""" @@ -692,7 +697,7 @@ class TestMake(unittest.TestCase): mock_run_one.return_value = mock_result # Simulate loop detection by setting _terminated during the call - def side_effect(*args, **kwargs): + def side_effect(*_args, **kwargs): # Simulate output_func being called with loop data output_func = kwargs.get('output_func') if output_func: @@ -822,7 +827,7 @@ class TestPrintBuildSummary(unittest.TestCase): start_time = datetime(2024, 1, 1, 12, 0, 0) end_time = datetime(2024, 1, 1, 12, 0, 10) mock_datetime.now.return_value = end_time - mock_datetime.side_effect = lambda *args, **kwargs: datetime(*args, **kwargs) + mock_datetime.side_effect = datetime terminal.get_print_test_lines() # Clear self.handler.print_build_summary(100, 0, 0, start_time, []) @@ -839,7 +844,7 @@ class TestPrintBuildSummary(unittest.TestCase): start_time = datetime(2024, 1, 1, 12, 0, 0) end_time = datetime(2024, 1, 1, 12, 0, 10, 600000) # 10.6 seconds mock_datetime.now.return_value = end_time - mock_datetime.side_effect = lambda *args, **kwargs: datetime(*args, **kwargs) + mock_datetime.side_effect = datetime terminal.get_print_test_lines() # Clear self.handler.print_build_summary(100, 0, 0, start_time, [])