You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This test code was written by the `hypothesis.extra.ghostwriter` module# and is provided under the Creative Commons Zero public domain dedication.importexamplefromhypothesisimportgiven, strategiesasst@given(list_example=st.lists(st.builds(NestedExample)))deftest_fuzz_Example(list_example):
example.Example(list_example=list_example)
@given(name=st.text())deftest_fuzz_NestedExample(name):
example.NestedExample(name=name)
@given(cls=st.none(),init=st.booleans(),repr=st.booleans(),eq=st.booleans(),order=st.booleans(),unsafe_hash=st.booleans(),frozen=st.booleans(),)deftest_fuzz_dataclass(cls, init, repr, eq, order, unsafe_hash, frozen):
example.dataclass(
cls,
init=init,
repr=repr,
eq=eq,
order=order,
unsafe_hash=unsafe_hash,
frozen=frozen,
)
This is missing an import for NestedExample
It appears that within _imports_for_strategy() we need to check for strategy being a ListStrategy, and in that case call _imports_for_strategy(strategy.element_strategy).
There is a complication in that TextStrategy also inherits from ListStrategy. On my own branch I currently check for the following
# get the underlying strategy for elements of a listifisinstance(strategy, ListStrategy) andnotisinstance(strategy, TextStrategy):
imports |= _imports_for_strategy(strategy.element_strategy)
but am open to suggestions as to the best way to handle this.
The text was updated successfully, but these errors were encountered:
Thanks for the report @strue36! I think your fix looks good here, though we can simplify it further - it's fine to add the imports for the elements of a TextStrategy, and simpler code is worth the (too-small-to-measure) perf hit here I think.
If you'd like to open a PR for this, I'd be delighted to accept it - just remember to add the RELEASE.rst and your name to the list in AUTHORS.rst 😁
Given the following file
example.pyThe output of hypothesis write is
This is missing an import for
NestedExampleIt appears that within
_imports_for_strategy()we need to check for strategy being aListStrategy, and in that case call_imports_for_strategy(strategy.element_strategy).There is a complication in that
TextStrategyalso inherits fromListStrategy. On my own branch I currently check for the followingbut am open to suggestions as to the best way to handle this.
The text was updated successfully, but these errors were encountered: