]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/functional/m68k: Avoid ResourceWarning in the nextcube test
authorThomas Huth <thuth@redhat.com>
Fri, 29 Aug 2025 14:20:00 +0000 (16:20 +0200)
committerThomas Huth <thuth@redhat.com>
Tue, 9 Sep 2025 07:44:46 +0000 (09:44 +0200)
Since commit c3fd296cf7b1 ("functional: always enable all python
warnings") we enabled more warnings for the functional tests. This
triggers now a warning in the nextcube test:

 tests/functional/m68k/test_nextcube.py:47: ResourceWarning:
  unclosed file <_io.BufferedReader name='tests/functional/m68k/test_nextcube.NextCubeMachine.test_bootrom_framebuffer_size/scratch/dump.ppm'>
   width, height = Image.open(screenshot_path).size

Use a proper "with" context to avoid it.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20250829142000.62320-1-thuth@redhat.com>

tests/functional/m68k/test_nextcube.py

index 13c72bd136a82cda5cad2d421867be66c8b30784..c1610e58456fa6abf0ea64202366b96dc05120aa 100755 (executable)
@@ -44,7 +44,8 @@ class NextCubeMachine(QemuSystemTest):
         self.check_bootrom_framebuffer(screenshot_path)
 
         from PIL import Image
-        width, height = Image.open(screenshot_path).size
+        with Image.open(screenshot_path) as image:
+                width, height = image.size
         self.assertEqual(width, 1120)
         self.assertEqual(height, 832)