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

Parametrize test_lib_pack.py #8026

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Apr 27, 2024

No description provided.

mode: str, rawmode: str, data: int | bytes, pixels: list[float | tuple[int, ...]]
) -> None:
with pytest.raises(ValueError):
test_unpack(mode, rawmode, data, pixels)
Copy link
Member

Choose a reason for hiding this comment

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

Calling one test from another seems odd, and a potential source of confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could make test_unpack not a test function, and have all three test functions call that, but I don't see how that would be any clearer.

@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from 84850ef to 7a474fc Compare May 15, 2024 15:59
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from b0a2b1e to 1fa2ace Compare May 23, 2024 13:28
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch 2 times, most recently from a7b62a4 to 39d1fb5 Compare June 8, 2024 14:28
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from 39d1fb5 to 9b6dbba Compare June 15, 2024 15:09
@radarhere
Copy link
Member

I understand there's a lot of repetition in this file, but I don't think that this version is easier to understand.

If others think it is easier to understand, that's fine, but those are my thoughts on the matter.

@Yay295
Copy link
Contributor Author

Yay295 commented Jun 22, 2024

It's much easier to understand when a test fails.

@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch 4 times, most recently from bf9cc8a to 7458a24 Compare June 28, 2024 20:33
@radarhere
Copy link
Member

While I recognise I'm not as fond of parametrisation as others, I think over 200 and 500 lines of code to construct the parameters is a bit much.

If the concern is about clarity when a test fails, maybe just adding a message to the assertion would be a smaller change with a similar effect? Something like this, but with the details about which case failed as the message.

assert webp_icc_profile == expected_icc_profile, "Webp ICC didn't match"

@Yay295
Copy link
Contributor Author

Yay295 commented Jun 29, 2024

The main benefit I see for parametrization is that each assert can fail on its own, instead of the test stopping at the first failed assert.

@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from b662aef to d72e29f Compare July 19, 2024 13:53
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

2 participants