[PATCH 1/1] test: avoid function name 'setup'

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Sat Jul 15 11:05:22 CEST 2023


pytest 7.3.2 treats the function name 'setup' as a fixture [1].

This leads to errors like:

    TypeError: setup() missing 2 required positional arguments:
    'disk_img' and 'osindications'

Rename setup() to capsule_setup().

[1] How to run tests written for nose
    https://docs.pytest.org/en/7.3.x/how-to/nose.html

Fixes: 482ef90aeb4c ("test: efi_capsule: refactor efi_capsule test")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 test/py/tests/test_efi_capsule/capsule_common.py     |  2 +-
 .../test_efi_capsule/test_capsule_firmware_fit.py    | 10 +++++-----
 .../test_efi_capsule/test_capsule_firmware_raw.py    | 12 ++++++------
 .../test_capsule_firmware_signed_fit.py              | 12 ++++++------
 .../test_capsule_firmware_signed_raw.py              | 12 ++++++------
 5 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/test/py/tests/test_efi_capsule/capsule_common.py b/test/py/tests/test_efi_capsule/capsule_common.py
index 9eef6767a6..fc0d851c61 100644
--- a/test/py/tests/test_efi_capsule/capsule_common.py
+++ b/test/py/tests/test_efi_capsule/capsule_common.py
@@ -6,7 +6,7 @@
 
 from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR
 
-def setup(u_boot_console, disk_img, osindications):
+def capsule_setup(u_boot_console, disk_img, osindications):
     """setup the test
 
     Args:
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py
index a3094c33f4..11bcdc2bb2 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py
@@ -8,7 +8,7 @@ This test verifies capsule-on-disk firmware update for FIT images
 
 import pytest
 from capsule_common import (
-    setup,
+    capsule_setup,
     init_content,
     place_capsule_file,
     exec_manual_update,
@@ -49,7 +49,7 @@ class TestEfiCapsuleFirmwareFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test05']
         with u_boot_console.log.section('Test Case 1-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -81,7 +81,7 @@ class TestEfiCapsuleFirmwareFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test04']
         with u_boot_console.log.section('Test Case 2-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -116,7 +116,7 @@ class TestEfiCapsuleFirmwareFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test104']
         with u_boot_console.log.section('Test Case 3-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -165,7 +165,7 @@ class TestEfiCapsuleFirmwareFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test105']
         with u_boot_console.log.section('Test Case 4-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py
index 80d791e3de..a5b5c8a385 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py
@@ -8,7 +8,7 @@ This test verifies capsule-on-disk firmware update for raw images
 
 import pytest
 from capsule_common import (
-    setup,
+    capsule_setup,
     init_content,
     place_capsule_file,
     exec_manual_update,
@@ -51,7 +51,7 @@ class TestEfiCapsuleFirmwareRaw:
         disk_img = efi_capsule_data
         capsule_files = ['Test03']
         with u_boot_console.log.section('Test Case 1-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -83,7 +83,7 @@ class TestEfiCapsuleFirmwareRaw:
         disk_img = efi_capsule_data
         capsule_files = ['Test01', 'Test02']
         with u_boot_console.log.section('Test Case 2-a, before reboot'):
-            setup(u_boot_console, disk_img, None)
+            capsule_setup(u_boot_console, disk_img, None)
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -111,7 +111,7 @@ class TestEfiCapsuleFirmwareRaw:
         disk_img = efi_capsule_data
         capsule_files = ['Test01', 'Test02']
         with u_boot_console.log.section('Test Case 3-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -157,7 +157,7 @@ class TestEfiCapsuleFirmwareRaw:
         disk_img = efi_capsule_data
         capsule_files = ['Test101', 'Test102']
         with u_boot_console.log.section('Test Case 4-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -211,7 +211,7 @@ class TestEfiCapsuleFirmwareRaw:
         disk_img = efi_capsule_data
         capsule_files = ['Test103']
         with u_boot_console.log.section('Test Case 5-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
index 94d6c3eef0..44a58baa31 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
@@ -11,7 +11,7 @@ with signed capsule files containing FIT images
 
 import pytest
 from capsule_common import (
-    setup,
+    capsule_setup,
     init_content,
     place_capsule_file,
     exec_manual_update,
@@ -47,7 +47,7 @@ class TestEfiCapsuleFirmwareSignedFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test13']
         with u_boot_console.log.section('Test Case 1-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -76,7 +76,7 @@ class TestEfiCapsuleFirmwareSignedFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test14']
         with u_boot_console.log.section('Test Case 2-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -107,7 +107,7 @@ class TestEfiCapsuleFirmwareSignedFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test02']
         with u_boot_console.log.section('Test Case 3-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -137,7 +137,7 @@ class TestEfiCapsuleFirmwareSignedFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test114']
         with u_boot_console.log.section('Test Case 4-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -176,7 +176,7 @@ class TestEfiCapsuleFirmwareSignedFit():
         disk_img = efi_capsule_data
         capsule_files = ['Test115']
         with u_boot_console.log.section('Test Case 5-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
index ad2b1c6324..83a10e160b 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
@@ -9,7 +9,7 @@ with signed capsule files containing raw images
 
 import pytest
 from capsule_common import (
-    setup,
+    capsule_setup,
     init_content,
     place_capsule_file,
     exec_manual_update,
@@ -44,7 +44,7 @@ class TestEfiCapsuleFirmwareSignedRaw():
         disk_img = efi_capsule_data
         capsule_files =  ['Test11']
         with u_boot_console.log.section('Test Case 1-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -72,7 +72,7 @@ class TestEfiCapsuleFirmwareSignedRaw():
         disk_img = efi_capsule_data
         capsule_files = ['Test12']
         with u_boot_console.log.section('Test Case 2-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -101,7 +101,7 @@ class TestEfiCapsuleFirmwareSignedRaw():
         disk_img = efi_capsule_data
         capsule_files = ['Test02']
         with u_boot_console.log.section('Test Case 3-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -131,7 +131,7 @@ class TestEfiCapsuleFirmwareSignedRaw():
         disk_img = efi_capsule_data
         capsule_files = ['Test111', 'Test112']
         with u_boot_console.log.section('Test Case 4-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
@@ -175,7 +175,7 @@ class TestEfiCapsuleFirmwareSignedRaw():
         disk_img = efi_capsule_data
         capsule_files = ['Test113']
         with u_boot_console.log.section('Test Case 5-a, before reboot'):
-            setup(u_boot_console, disk_img, '0x0000000000000004')
+            capsule_setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
 
-- 
2.40.1



More information about the U-Boot mailing list