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 07efbd8 to 576d001 Compare July 9, 2024 00:14
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch 2 times, most recently from b662aef to d72e29f Compare July 19, 2024 13:53
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch 2 times, most recently from 0bc6c55 to 474e85b Compare August 1, 2024 14:58
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from 474e85b to 35be6ec Compare August 14, 2024 13:27
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from 35be6ec to 37280ee Compare August 28, 2024 13:09
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from 37280ee to 46cdd31 Compare September 18, 2024 19:43
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from 46cdd31 to 111994a Compare September 30, 2024 13:22
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from 111994a to edb8efd Compare October 7, 2024 13:52
@Yay295 Yay295 force-pushed the parametrize_test_lib_pack branch from edb8efd to 9c64378 Compare October 12, 2024 23:19
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.

2 participants