From 08aa8800dda184bb86b28ea513ca53ae98896b30 Mon Sep 17 00:00:00 2001 From: Vladyslav Timofeev Date: Sun, 10 Mar 2024 23:00:40 +0000 Subject: [PATCH] fix tests on windows --- tests/test_response.py | 3 ++- tests/test_staticfiles.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_response.py b/tests/test_response.py index 73cebee..4f303af 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -1,4 +1,5 @@ import itertools +import re from contextlib import AbstractContextManager, nullcontext from datetime import datetime, timedelta, UTC from email.utils import format_datetime @@ -142,7 +143,7 @@ def test_invalid_file_path(tmp_path: Path) -> None: directory.mkdir() with pytest.raises( - ValueError, match=f"'{directory}' is not a valid file path" + ValueError, match=re.escape(f"'{directory}' is not a valid file path") ): FileResponse(directory) diff --git a/tests/test_staticfiles.py b/tests/test_staticfiles.py index 1da559f..6b997cf 100644 --- a/tests/test_staticfiles.py +++ b/tests/test_staticfiles.py @@ -1,3 +1,4 @@ +import re from pathlib import Path from unittest.mock import Mock, create_autospec @@ -24,7 +25,9 @@ def test_create_staticfiles_with_nonexistent_directory(tmp_path: Path) -> None: with pytest.raises( NotADirectoryError, - match=f"Directory {str(directory)!r} does not exist or is not a directory", + match=re.escape( + f"Directory {str(directory)!r} does not exist or is not a directory" + ), ): StaticFiles(directory=directory) @@ -37,7 +40,9 @@ def test_create_staticfiles_with_file_instead_of_directory( with pytest.raises( NotADirectoryError, - match=f"Directory {str(file)!r} does not exist or is not a directory", + match=re.escape( + f"Directory {str(file)!r} does not exist or is not a directory" + ), ): StaticFiles(directory=file)