diff --git a/tests/test_core.py b/tests/test_core.py index 5f824f9e53ad35..29e3bf89137249 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -9,6 +9,7 @@ import gc import logging import os +from pathlib import Path import re from tempfile import TemporaryDirectory import threading @@ -2009,8 +2010,9 @@ async def test_config_is_allowed_path() -> None: config.allowlist_external_dirs = {os.path.realpath(tmp_dir)} test_file = os.path.join(tmp_dir, "test.jpg") - with open(test_file, "w", encoding="utf8") as tmp_file: - tmp_file.write("test") + await asyncio.get_running_loop().run_in_executor( + None, Path(test_file).write_text, "test" + ) valid = [test_file, tmp_dir, os.path.join(tmp_dir, "notfound321")] for path in valid: