Skip to content

feat: allow xpath for test regression against element + Windows support #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2022
Merged

feat: allow xpath for test regression against element + Windows support #2

merged 1 commit into from
Mar 16, 2022

Conversation

matslindh
Copy link
Contributor

Warning: This patch does two things, which I sadly didn't have time to split out into separate PRs.

  1. Allow a user to give an optional xpath qualifier when calling screenshot_regression. The regression will then be tested against this single element instead of the whole page.
  2. Make pytest-image-diff with splinter work properly on Windows (see issue Using NamedTemporaryFile doesn't behave as expected on Windows #1). Since Windows requires us to close the temp file first, we make the temp file persistent, close it, and then tells splinter to write to it. Afterwards we clean up the temporary file before returning from the function.

Warning: This patch does two things, which I sadly didn't have time to split out into separate PRs.

1) Allow a user to give an optional `xpath` qualifier when calling `screenshot_regression`. The regression will then be tested against this single element instead of the whole page.
2) Make pytest-image-diff with splinter work properly on Windows (see issue #1). Since Windows requires us to close the temp file first, we make the temp file persistent, close it, and then tells splinter to write to it. Afterwards we clean up the temporary file before returning from the function.
@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #2 (031f4fb) into master (7f74780) will decrease coverage by 13.32%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master       #2       +/-   ##
===========================================
- Coverage   54.89%   41.56%   -13.33%     
===========================================
  Files           6        6               
  Lines         235      243        +8     
  Branches       40       42        +2     
===========================================
- Hits          129      101       -28     
- Misses         94      131       +37     
+ Partials       12       11        -1     
Impacted Files Coverage Δ
pytest_image_diff/splinter.py 0.00% <0.00%> (-33.34%) ⬇️
pytest_image_diff/helpers.py 38.09% <0.00%> (-19.05%) ⬇️
pytest_image_diff/plugin.py 57.14% <0.00%> (-8.17%) ⬇️
pytest_image_diff/image_diff.py 53.70% <0.00%> (-5.56%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f74780...031f4fb. Read the comment docs.

@matslindh
Copy link
Contributor Author

Seems like the missing_ok parameter was added in 3.8. I'll see if I can patch it to catch the exception if it doesn't exist instead.

@Apkawa
Copy link
Owner

Apkawa commented Mar 15, 2022

Hello!
Thanks for PR!
Some checks failed, but i may reviewed and add additional checks.

@Apkawa Apkawa changed the base branch from master to PR2_xpath March 16, 2022 10:32
@Apkawa Apkawa merged commit 80b9b17 into Apkawa:PR2_xpath Mar 16, 2022
@matslindh matslindh deleted the add-xpath-to-screenshot-regression-and-windows-compatibility-fix branch July 5, 2022 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants