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

Consolidate getdata and putdata tests #8017

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Apr 25, 2024

Moved all of the getdata and putdata tests to the same file (because test_getdata_putdata doesn't fit in either individual file), and parametrized two tests.

@radarhere
Copy link
Member

test_image_getdata_putdata.py seems like a mouthful. How about just test_image_data.py?

@Yay295
Copy link
Contributor Author

Yay295 commented Apr 28, 2024

sure

Yay295 and others added 6 commits April 27, 2024 22:40
This test had some duplicate checks because originally in Python 2 the numbers in those lines had a "L" suffix, which is no longer used in Python 3.
The original bug this was referring to seems to have been lost, but it looks to have been something to do with Python 2/3 compatibility and big numbers.
See commit c8ce29c and python-pillow#7991.
Co-authored-by: Ondrej Baranovič <ondreko.tiba@gmail.com>
@radarhere
Copy link
Member

Moved all of the getdata and putdata tests to the same file (because test_getdata_putdata doesn't fit in either individual file)

Sorry, I've just realised what this meant. In main, we currently have test_image_getdata.py and test_image_putdata.py, and here you've merged them together into a single file because you'd like to find a new home for a test from test_image.py / #7209, and you don't think a roundtrip test belongs in either file.

I think test_image_putdata.py already has roundtrip tests, using both getdata() and putdata().

@pytest.mark.parametrize("mode", ("I", "I;16", "I;16L", "I;16B"))
def test_mode_i(mode: str) -> None:
src = hopper("L")
data = list(src.getdata())
im = Image.new(mode, src.size, 0)
im.putdata(data, 2, 256)
target = [2 * elt + 256 for elt in data]
assert list(im.getdata()) == target

@Yay295
Copy link
Contributor Author

Yay295 commented Apr 28, 2024

I'd say those should be in the combined file for the same reason. Though I suppose I shouldn't have added putdata to those function names.

@Yay295
Copy link
Contributor Author

Yay295 commented Apr 28, 2024

Cleaned up the tests a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants