-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-107862: Add roundtrip hypothesis
tests to test_binascii
#107863
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
Conversation
sobolevn
commented
Aug 11, 2023
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: [Meta] Research: what can we test with Hypothesis? #107862
Closing and re-opening to retrigger CLA checks. Sorry for the noise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
@hypothesis.given(binary=hypothesis.strategies.binary()) | ||
def test_hex_roundtrip(self, binary): | ||
converted = binascii.hexlify(self.type2test(binary)) | ||
restored = binascii.unhexlify(self.type2test(converted)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if unhexlify should also take a sep and bytes_per_sep argument
Btw, @rhettinger was against doing this. |
I agree that we shouldn't rely on Hypothesis' strategies as a substitute for fixed tests. But I think the implementation chosen for adding property based tests in CPython is quite sensible! None of the Hypothesis strategies run by default in our test suite. Hypothesis is stubbed out and simply used used as a DSL to write property based tests where For this specific PR, I guess maybe I should have asked Nikita to add some specific (I also obviously agree we shouldn't use Hypothesis to write tests to enforce properties that are not actually properties, like the colorsys example) |