From 03cf6f9348ee6ae2ba55bfad745f74c81259d597 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 1 Apr 2026 20:01:28 +0530 Subject: [PATCH] Fix unclosed resource warning in test --- kitty_tests/dnd.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kitty_tests/dnd.py b/kitty_tests/dnd.py index a2792ba4c..19ee84225 100644 --- a/kitty_tests/dnd.py +++ b/kitty_tests/dnd.py @@ -633,10 +633,14 @@ class TestDnDProtocol(BaseTest): bc_content = bytes(range(256)) * 20 # binary data bde_content = b'deep nested file\n' - (open(os.path.join(root, 'a.txt'), 'wb')).write(a_content) + def w(data, *a): + with open(os.path.join(root, *a), 'wb') as f: + f.write(data) + + w(a_content, 'a.txt') os.makedirs(os.path.join(root, 'b', 'd')) - (open(os.path.join(root, 'b', 'c.txt'), 'wb')).write(bc_content) - (open(os.path.join(root, 'b', 'd', 'e.txt'), 'wb')).write(bde_content) + w(bc_content, 'b', 'c.txt') + w(bde_content, 'b', 'd', 'e.txt') uri_list = f'file://{root}\r\n'.encode() with dnd_test_window() as (osw, wid, screen, cap):