Skip to content

Commit

Permalink
Add fullpath option to ImageRegression (#184)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Bruno Oliveira <[email protected]>
  • Loading branch information
12rambau and nicoddemus authored Jan 9, 2025
1 parent 05be0bb commit 47df8d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ UNRELEASED

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


2.6.0
Expand Down
7 changes: 7 additions & 0 deletions src/pytest_regressions/image_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def check(
diff_threshold: float = 0.1,
expect_equal: bool = True,
basename: Optional[str] = None,
fullpath: Optional["os.PathLike[str]"] = None,
) -> None:
"""
Checks that the given image contents are comparable with the ones stored in the data directory.
Expand All @@ -148,6 +149,11 @@ def check(
image should be considered different at least above the threshold.
:param diff_threshold:
Tolerance as a percentage (1 to 100) on how the images are allowed to differ.
:param fullpath: complete path to use as a reference file. This option
will ignore ``datadir`` fixture when reading *expected* files but will still use it to
write *obtained* files. Useful if a reference file is located in the session data dir for example.
``basename`` and ``fullpath`` are exclusive.
"""
__tracebackhide__ = True

Expand All @@ -172,6 +178,7 @@ def dump_fn(target: Path) -> None:
dump_fn=dump_fn,
extension=".png",
basename=basename,
fullpath=fullpath,
force_regen=self.force_regen,
with_test_class_names=self.with_test_class_names,
)

0 comments on commit 47df8d5

Please sign in to comment.