Repository navigation
Convert some tests to pytest style - #4369
Merged
Merged
Conversation
To better follow conventional pytest style, this removes the outer wrapper class in favor of a function for some tests. These tests were picked as they are relatively simple and presented no barriers to a quick port. The assert* methods are replaced with assert statements. When necessary, a fixture is used to create a temporary directory. This commit does not convert the entire test suite to this style as some test classes use methods or other advanced features that are difficult to automatically convert. The goal is to address these issues in followup commits. Refs #4193
hugovk
reviewed
Jan 18, 2020
| im.load() | ||
|
|
||
|
|
||
| def test_save(tmp_path): |
Member
There was a problem hiding this comment.
Noting something new to me, this looks handy:
The
tmp_pathfixture
Member
|
I'm fine with this. Any comments from anyone else? I tried timing running the changed tests in this commit (using pytest) vs. the previous commit (using unittest), and the numbers were more or less inconclusive.
for i in {1..100}; do pytest Tests/test_000_sanity.py Tests/test_binary.py Tests/test_box_blur.py Tests/test_core_resources.py Tests/test_file_bufrstub.py Tests/test_file_container.py Tests/test_file_gd.py Tests/test_file_gimppalette.py Tests/test_file_wal.py Tests/test_format_lab.py Tests/test_image_getbands.py Tests/test_image_getbbox.py Tests/test_image_getim.py Tests/test_image_getpalette.py Tests/test_image_putpalette.py Tests/test_image_tobytes.py Tests/test_imagestat.py Tests/test_locale.py Tests/test_main.py Tests/test_util.py; done |
Member
|
Alright, let's go ahead with this. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To better follow conventional pytest style, this removes the outer
wrapper class in favor of a function for some tests. These tests were
picked as they are relatively simple and presented no barriers to a
quick port. The assert* methods are replaced with assert statements.
When necessary, a fixture is used to create a temporary directory.
This commit does not convert the entire test suite to this style as some
test classes use methods or other advanced features that are difficult
to automatically convert. The goal is to address these issues in
followup commits.
Refs #4193
To reviewers, I'm happy expand or shrink the scope of this change as desired. If there is a preference for this to be split up over multiple commits, let me know. I'm happy to make adjustments.