Skip to content

Conversation

@sobolevn
Copy link
Member

@sobolevn sobolevn commented Aug 11, 2023

@ambv
Copy link
Contributor

ambv commented Aug 11, 2023

Closing and re-opening to retrigger CLA checks. Sorry for the noise.

@ambv ambv closed this Aug 11, 2023
@ambv ambv reopened this Aug 11, 2023
Copy link
Contributor

@hauntsaninja hauntsaninja left a 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))
Copy link
Contributor

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

@hauntsaninja hauntsaninja enabled auto-merge (squash) September 1, 2023 21:04
@hauntsaninja hauntsaninja merged commit 3b73f9f into python:main Sep 1, 2023
@sobolevn
Copy link
Member Author

sobolevn commented Sep 1, 2023

Btw, @rhettinger was against doing this.

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Sep 1, 2023

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 @hypothesis.example is used to provide the fixed test cases. However, if we wish, we can opt-in to get the real non-stub Hypothesis to run its strategies against the already written test because it's in a DSL it understands.

For this specific PR, I guess maybe I should have asked Nikita to add some specific @hypothesis.example here. Raymond, I'm happy to open a PR adding examples, or to revert, or to let it be. Just let me know!

(I also obviously agree we shouldn't use Hypothesis to write tests to enforce properties that are not actually properties, like the colorsys example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants