]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: Update fit test to fix a few Python warnings
authorSimon Glass <sjg@chromium.org>
Mon, 13 Apr 2026 12:59:56 +0000 (06:59 -0600)
committerTom Rini <trini@konsulko.com>
Wed, 22 Apr 2026 22:52:14 +0000 (16:52 -0600)
Fix some warnings and disable one that cannot be fixed.

Signed-off-by: Simon Glass <sjg@chromium.org>
test/py/tests/test_fit.py

index 9bfe25c0a5121f52a99a2bf7f1b76e2dcc3009fb..6a8649792cfefc2022e855eaf3230e8d2b85c83c 100755 (executable)
@@ -1,13 +1,14 @@
 # SPDX-License-Identifier:     GPL-2.0+
 # Copyright (c) 2013, Google Inc.
-#
-# Sanity check of the FIT handling in U-Boot
+
+"""Sanity check of the FIT handling in U-Boot"""
 
 import os
-import pytest
 import struct
-import utils
+
+import pytest
 import fit_util
+import utils
 
 # Define a base ITS which we can adjust using % and a dictionary
 base_its = '''
@@ -160,8 +161,8 @@ def test_fit_base(ubman):
         fname = make_fname(filename)
         data = ''
         for i in range(100):
-            data += '%s %d was seldom used in the middle ages\n' % (text, i)
-        with open(fname, 'w') as fd:
+            data += f'{text} {i} was seldom used in the middle ages\n'
+        with open(fname, 'w', encoding='ascii') as fd:
             print(data, file=fd)
         return fname
 
@@ -202,6 +203,7 @@ def test_fit_base(ubman):
                           'third_line:')
         '30'
         """
+        # pylint: disable=W0612
         __tracebackhide__ = True
         for line in '\n'.join(text).splitlines():
             pos = line.find(match)
@@ -209,6 +211,7 @@ def test_fit_base(ubman):
                 return line[:pos] + line[pos + len(match):]
 
         pytest.fail("Expected '%s' but not found in output")
+        return '<no-match>'
 
     def check_equal(expected_fname, actual_fname, failure_msg):
         """Check that a file matches its expected contents