Skip to content

Commit 93a149a

Browse files
authored
fix: OSError: exception for windows (#8)
`OSError: [WinError [...The filename, directory name, or volume label syntax is incorrect: `
1 parent 8ab52fb commit 93a149a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pytest_image_diff/plugin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
from typing import Optional, NamedTuple, cast, Callable, Generator, Union
34

45
import pytest
@@ -62,7 +63,7 @@ def image_diff_dir(image_diff_root: str) -> PathType:
6263
"""
6364
Path for store diff images. by default - '{image_diff_root}.tests/image_diff/'
6465
"""
65-
return os.path.join(image_diff_root, ".tests/image_diff/")
66+
return os.path.join(image_diff_root, ".tests", "image_diff")
6667

6768

6869
@pytest.fixture(scope="session")
@@ -123,8 +124,8 @@ def _image_diff_info(
123124

124125
def _factory(image: ImageFileType, suffix: Optional[str] = None) -> DiffInfo:
125126
test_info = get_test_info(request)
126-
class_name = test_info.class_name
127-
test_name = test_info.test_name
127+
class_name = re.sub(r'[^\w_. -]', '_', test_info.class_name)
128+
test_name = re.sub(r'[^\w_. -]', '_', test_info.test_name)
128129
if suffix is None:
129130
# Todo enumerate every call
130131
suffix = ""

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def image_diff_dir(image_diff_root: str) -> PathType:
2020
"""
2121
Path for store diff images. by default - '{image_diff_root}.tests/image_diff/'
2222
"""
23-
return pathlib.Path(image_diff_root) / ".tests/image_diff/"
23+
return pathlib.Path(image_diff_root) / ".tests" / "image_diff"

0 commit comments

Comments
 (0)