bpo-41734: refactor b32{encode,decode} tests#22122
Conversation
Matching b32hex{encode,decode}.
Signed-off-by: Filipe Laíns <lains@archlinux.org>
|
cc @pganssle |
pganssle
left a comment
There was a problem hiding this comment.
I'm +1 on this, but I think it should probably have a news entry, even though it only affects the tests, in case it breaks something for downstream redistributors for some reason.
Given that there's a tests section to the Changelog, I think we may as well err on the side of caution here.
| eq(base64.b32decode(data, True), res) | ||
| eq(base64.b32decode(data.decode('ascii'), True), res) | ||
| def test_b32hexdecode(self): | ||
| test_cases = [ |
There was a problem hiding this comment.
I feel like we've had this conversation before and I must have been convinced otherwise, but I can't help but think that this might be a bit easier to read as some variation on this:
test_cases = [
(to_decode, expected, casefold)
for casefold in [True, False]
for to_decode, expected in [
# to_decode, expected
(b'', b'')
(b'AA======', b'\x00'),
(b'ME======', b'a'),
(b'MFRA====', b'ab'),
(b'MFRGG===', b'abc'),
(b'MFRGGZA=', b'abcd'),
(b'MFRGGZDF', b'abcde'),
]] + [
# to_decode, expected, casefold
(b'me======', b'a', True),
(b'mfra====', b'ab', True),
(b'mfrgg===', b'abc', True),
(b'mfrggza=', b'abcd', True),
(b'mfrggzdf', b'abcde', True),
]Downsides: It's got a control structure in it, and the final version of it isn't fully "spelled out".
Upsides: The test cases that are tested with both casefold=True and casefold=False are much more clearly delineated from the ones that are only tested with casefold=True, and the test cases aren't repeated.
I'm on the fence so I'll defer to the author in case anyone else feels strongly about it.
There was a problem hiding this comment.
I can make that change, sure.
There was a problem hiding this comment.
Personally I find the less logic in tests, the better. Flat list of cases is the easiest to read and change. I even like the alignment of entries which I strongly dislike in regular code! 🙂
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
|
Before putting any more work into this can we discuss it in BPO as @serhiy-storchaka marked it as rejected? |
|
@FFY00 2.5 years passed with no reconsideration. Should this stylistic PR and associated issue be closed then? |
|
Yeah, closing this. |
Matching b32hex{encode,decode}.
Signed-off-by: Filipe Laíns lains@archlinux.org
https://bugs.python.org/issue41734