Skip to content
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

TST: simplify test_get_images #2668

Merged
merged 7 commits into from
May 24, 2024

Conversation

tibor-reiss
Copy link
Contributor

@tibor-reiss tibor-reiss commented May 22, 2024

Fixes #2428

Imho, the test does too many things. Thus, instead of replacing with e.g. txt_file_path fixture, I removed things:

  • write to file: The written file is never used. What was the reason to add it here in this test? -> Update: added back with tmp_path
  • TypeError: does not seem to fit into this test -> Update: new test in test_page.py

Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.00%. Comparing base (109ef4a) to head (190b4fa).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2668   +/-   ##
=======================================
  Coverage   95.00%   95.00%           
=======================================
  Files          50       50           
  Lines        8356     8356           
  Branches     1673     1673           
=======================================
  Hits         7939     7939           
  Misses        259      259           
  Partials      158      158           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pubpub-zz
Copy link
Collaborator

Fixes #2428

Imho, the test does too many things. Thus, instead of replacing with e.g. txt_file_path fixture, I removed things:

* write to file: The written file is never used. What was the reason to add it here in this test?

This may be expected to check that no exception are raised

* TypeError: does not seem to fit into this test

Have not been able to get through

I've rerun the checks to confirm coverage and your PR has reduced the test coverage. Can you please revisit it ?

@tibor-reiss
Copy link
Contributor Author

tibor-reiss commented May 22, 2024

@pubpub-zz Thanks for the quick feedback! I have added a new test to test_page.py so to cover the TypeError. And I added back the writing of the file - now with the tmp_path.

@pubpub-zz
Copy link
Collaborator

to prevent writing you may perhaps have a look at test_corrupted_jpeg_iss2266 in test_images.py

@tibor-reiss
Copy link
Contributor Author

@pubpub-zz Would you like to check for similarity as in test_corrupted_jpeg_iss2266? For that I would need to add Image9.png to e.g. sample-files. Or would you prefer the Image.open(BytesIO...) construct? This is already part of the last assert though.

@stefan6419846
Copy link
Collaborator

Do we really need to write to the file system? Shouldn't writing to BytesIO() have the same effect without explicitly accessing the file system?

@tibor-reiss
Copy link
Contributor Author

@pubpub-zz, @stefan6419846 I might be wrong, but since the second assert has already the manipulations with BytesIO, is there anything still missing, please? Let me know if I am misunderstanding something - for now, I have removed the writing to file.

Copy link
Collaborator

@pubpub-zz pubpub-zz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of tmp_path, coverage looks good

tests/test_reader.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@stefan6419846 stefan6419846 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience.

@stefan6419846 stefan6419846 merged commit 12e4047 into py-pdf:main May 24, 2024
16 checks passed
@tibor-reiss tibor-reiss deleted the enh-2428-temp-files branch May 26, 2024 11:17
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.

Avoid creating files in current directory during tests
3 participants