From 4c5f4c4baf0e4c6dd87960a2030489bf2cbd8e1e Mon Sep 17 00:00:00 2001
From: Kovid Goyal <kovid@kovidgoyal.net>
Date: Wed, 14 Jun 2023 08:06:47 +0530
Subject: [PATCH] Apparently Python 3.12 no longer raises FileNotFoundError
when closing a deleted file
Fixes #6360 (I hope) dont have time to actually test with pre-release
python builds
---
kitty_tests/graphics.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kitty_tests/graphics.py b/kitty_tests/graphics.py
index d0d96eadf5..c9d6c4d123 100644
--- a/kitty_tests/graphics.py
+++ b/kitty_tests/graphics.py
@@ -8,6 +8,7 @@
import unittest
import zlib
from base64 import standard_b64decode, standard_b64encode
+from contextlib import suppress
from dataclasses import dataclass
from io import BytesIO
from itertools import cycle
@@ -364,9 +365,9 @@ def test_load_images(self):
self.assertTrue(os.path.exists(f.name))
f.seek(0), f.truncate(), f.write(compressed_random_data), f.flush()
sl(f.name, s=24, v=32, t='t', o='z', expecting_data=random_data)
- self.assertRaises(
- FileNotFoundError, f.close
- ) # check that file was deleted
+ self.assertFalse(os.path.exists(f.name), f'Temp file at {f.name} was not deleted')
+ with suppress(FileNotFoundError):
+ f.close()
# Test loading from POSIX SHM
name = '/kitty-test-shm'