Comments (5)
I agree that we should pick up any low-hanging improvements here, and this list looks pretty good to me.
Specific to the last point, we have a magic attribute used to distinguish @pytest.mark.parametrize()
d tests, which could also be used here. Just assign whatever bytestring you like, and it'll be hashed into the database key along with everything else, e.g.:
hypothesis/hypothesis-python/src/_hypothesis_pytestplugin.py
Lines 297 to 299 in 7b63483
from hypothesis.
It's actually pretty hard to derive a stable-across-runs bytestring from an arbitrary strategy; for example it's easy to end up with a repr that includes some object's memory address, or less often something like the current time or date or machine name or OS.
We strip the decorators from source code before hashing it so that adding or removing @settings()
and @example()
decorators doesn't affect the database key.
from hypothesis.
Hmm, I think we might add to the list
- Pick up
_hypothesis_internal_add_digest
from the currently executing test function instead of the function actually passed to given.
otherwise we'd duplicate keys for f.x.
@pytest.mark.parametrize("v", [1, 2])
def test_something(v):
@given(st.integers(v))
def inner(x):
assert x >= v
inner()
since the attribute is added to test_something
and not inner
. At that point, it might be more straightforward to just store the add_digest
as a global/threadlocal rather than as an attribute.
[edit] ...actually, we could mix in currently executing nodeid
regardless of parametrization... and call it a day. Too pytest specific?
from hypothesis.
[edit] ...actually, we could mix in currently executing
nodeid
regardless of parametrization... and call it a day. Too pytest specific?
Too specific - the problem is that if you execute a particular test function manually or via pytest, or a method with unittest or pytest, we want to have the same database key in either case. So mixing in the nodeid is fine when it's a parametrized test because there's a solid benefit and we're unlikely to execute it without pytest, but I'd prefer to avoid doing that unconditionally.
from hypothesis.
Understood, thanks! I have just one more question:
We don't use the strategy definition in our db key, and it looks intentional (e.g., _clean_source
in get_digest
and ignoring specifier
in find()
). This leads to collisions in find
(naturally), and also f.x. test_attrs_inference_builds
which is defined by the same name but slightly different strategy in two test modules.
Why is this? Is it beneficial to have key stability across changes in strategy?
from hypothesis.
Related Issues (20)
- Filter-rewriting for comparisons on dates, times, and datetimes
- `test_drawing_from_recursive_strategy_is_thread_safe` failed on Python 3.13.0b1
- Improve our internal coverage tests HOT 3
- Error when using from_type with optional integers with numeric constraints HOT 8
- Follow up on IR shrinking tasks
- `st.from_regex()` alphabet improvements
- Busy loop randomly runs 6x slower causing flaky DeadlineExceeded errors HOT 5
- Issues with django.forms.ModelChoiceField and ModelMultipleChoiceField HOT 1
- example generation regression between `6.47.0` -> `6.103.1` HOT 1
- `hypothesis.extra.pandas`: generate timezone-aware datetime columns
- Warning from tracer causes Flaky HOT 1
- Interest in a phone number strategy? HOT 1
- Improve testing story for Python 3.14 and free-threading builds
- `hypothesis codemod` doesn't update `Healthcheck.all()`
- Handle Django upgrades like Python versions in `./build.sh upgrade-requirements`
- Failing test for Django 5.0 HOT 1
- Using `builds` arguments for reprs may produce worse results than pretty printing HOT 2
- Improve error message when a package only has submodules for ghostwriter HOT 3
- Improve support for new and user-defined Numpy dtypes (e.g. `np.dtypes.StringDType`)
- Change Flaky to be an ExceptionGroup
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hypothesis.