Hypothesis itself does not have any dependencies, but there are some packages that need additional things installed in order to work.
You can install these dependencies using the setuptools extra feature as e.g.
pip install hypothesis[django]. This will check installation of compatible versions.
You can also just install hypothesis into a project using them, ignore the version constraints, and hope for the best.
In general “Which version is Hypothesis compatible with?” is a hard question to answer and even harder to regularly test. Hypothesis is always tested against the latest compatible version and each package will note the expected compatibility range. If you run into a bug with any of these please specify the dependency version.
This module provides
This module provides deprecated time and date related strategies.
It depends on the
pytz package, which is stable enough that almost any
version should be compatible - most updates are for the timezone database.
datetimes(allow_naive=None, timezones=None, min_year=None, max_year=None)¶
Return a strategy for generating datetimes.
Deprecated since version 3.9.0: use
allow_naive=True will cause the values to sometimes be naive. timezones is the set of permissible timezones. If set to an empty collection all datetimes will be naive. If set to None all timezones available via pytz will be used.
All generated datetimes will be between min_year and max_year, inclusive.
Return a strategy for generating dates.
Deprecated since version 3.9.0: use
All generated dates will be between min_year and max_year, inclusive.
Fake-factory is another Python library for data generation. hypothesis.extra.fakefactory is a package which lets you use fake-factory generators to parametrize tests.
The fake-factory API is extremely unstable, even between patch releases, and Hypothesis’s support for it is unlikely to work with anything except the exact version it has been tested against.
hypothesis.extra.fakefactory defines a function fake_factory which returns a strategy for producing text data from any FakeFactory provider.
So for example the following will parametrize a test by an email address:
>>> fake_factory('email').example() 'email@example.com' >>> fake_factory('name').example() 'Zbyněk Černý CSc.'
You can explicitly specify the locale (otherwise it uses any of the available locales), either as a single locale or as several:
>>> fake_factory('name', locale='en_GB').example() 'Antione Gerlach' >>> fake_factory('name', locales=['en_GB', 'cs_CZ']).example() 'Miloš Šťastný' >>> fake_factory('name', locales=['en_GB', 'cs_CZ']).example() 'Harm Sanford'
If you want to your own FakeFactory providers you can do that too, passing them in as a providers argument:
>>> from faker.providers import BaseProvider >>> class KittenProvider(BaseProvider): ... def meows(self): ... return 'meow %d' % (self.random_number(digits=10),) ... >>> fake_factory('meows', providers=[KittenProvider]).example() 'meow 9139348419'
Generally you probably shouldn’t do this unless you’re reusing a provider you already have - Hypothesis’s facilities for strategy generation are much more powerful and easier to use. Consider using something like BasicStrategy instead if you want to write a strategy from scratch. This is only here to provide easy reuse of things you already have.
hypothesis.extra.django adds support for testing your Django models with Hypothesis.
It is tested extensively against all versions of Django in mainstream or extended support, including LTS releases. It may be compatible with earlier versions too, but there’s no support from us either and you really should update to get security patches.
It’s large enough that it is documented elsewhere.