Skip to content

Commit 6a5e4f4

Browse files
committed
refactor: convert PosixPath to string in mock file handling for consistency
1 parent 8864e65 commit 6a5e4f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ def test_direct_setup_import(mock_setup):
272272
with mock.patch("builtins.open") as mock_open:
273273
# Configure the mock to return appropriate content for different files
274274
def side_effect(filename, *args, **kwargs):
275+
filename_str = str(filename) # Convert PosixPath to string
275276
for mock_path, content in mock_file_contents.items():
276-
if filename.endswith(mock_path):
277+
if filename_str.endswith(mock_path):
277278
file_mock = mock.MagicMock()
278279
file_mock.__enter__.return_value.read.return_value = content
279280
return file_mock
@@ -385,8 +386,9 @@ def test_version_info_not_found_error():
385386
with mock.patch("builtins.open") as mock_open:
386387
# Configure mock to return appropriate content for different files
387388
def side_effect(filename, *args, **kwargs):
389+
filename_str = str(filename) # Convert PosixPath to string
388390
for mock_path, content in mock_file_contents.items():
389-
if filename.endswith(mock_path):
391+
if filename_str.endswith(mock_path):
390392
file_mock = mock.MagicMock()
391393
file_mock.__enter__.return_value.read.return_value = content
392394
return file_mock

0 commit comments

Comments
 (0)