Skip to content

Commit 47df8d5

Browse files
12rambaunicoddemus
andauthored
Add fullpath option to ImageRegression (#184)
--------- Co-authored-by: Bruno Oliveira <[email protected]>
1 parent 05be0bb commit 47df8d5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ UNRELEASED
55

66
* Python 3.12 and 3.13 are now officially supported.
77
* Python 3.8 (EOL) is no longer supported.
8+
* `#184 <https://github.com/ESSS/pytest-regressions/pull/184>`__: Added ``fullpath`` parameter to ``image_regression.check``.
89

910

1011
2.6.0

src/pytest_regressions/image_regression.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def check(
137137
diff_threshold: float = 0.1,
138138
expect_equal: bool = True,
139139
basename: Optional[str] = None,
140+
fullpath: Optional["os.PathLike[str]"] = None,
140141
) -> None:
141142
"""
142143
Checks that the given image contents are comparable with the ones stored in the data directory.
@@ -148,6 +149,11 @@ def check(
148149
image should be considered different at least above the threshold.
149150
:param diff_threshold:
150151
Tolerance as a percentage (1 to 100) on how the images are allowed to differ.
152+
:param fullpath: complete path to use as a reference file. This option
153+
will ignore ``datadir`` fixture when reading *expected* files but will still use it to
154+
write *obtained* files. Useful if a reference file is located in the session data dir for example.
155+
156+
``basename`` and ``fullpath`` are exclusive.
151157
"""
152158
__tracebackhide__ = True
153159

@@ -172,6 +178,7 @@ def dump_fn(target: Path) -> None:
172178
dump_fn=dump_fn,
173179
extension=".png",
174180
basename=basename,
181+
fullpath=fullpath,
175182
force_regen=self.force_regen,
176183
with_test_class_names=self.with_test_class_names,
177184
)

0 commit comments

Comments
 (0)