Additional packages

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 pytz timezones.

You can use this strategy to make hypothesis.strategies.datetimes() and hypothesis.strategies.times() produce timezone-aware values.


Any timezone in the Olsen database, as a pytz tzinfo object.

This strategy minimises to UTC, or the smallest possible fixed offset, and is designed for use with hypothesis.strategies.datetimes().


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.

hypothesis.extra.datetime.datetimes(allow_naive=None, timezones=None, min_year=None, max_year=None)[source]

Return a strategy for generating datetimes.

Deprecated since version 3.9.0: use hypothesis.strategies.datetimes() instead.

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.

hypothesis.extra.datetime.dates(min_year=None, max_year=None)[source]

Return a strategy for generating dates.

Deprecated since version 3.9.0: use hypothesis.strategies.dates() instead.

All generated dates will be between min_year and max_year, inclusive.

hypothesis.extra.datetime.times(allow_naive=None, timezones=None)[source]

Return a strategy for generating times.

Deprecated since version 3.9.0: use hypothesis.strategies.times() instead.

The allow_naive and timezones arguments act the same as the datetimes strategy above.


faker is another Python library for data generation. hypothesis.extra.fakefactory is a package which lets you use Faker generators to parametrize tests. (tha name mismatch is because Faker used to be called fake-factory)

The Faker 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 Faker provider.

So for example the following will parametrize a test by an email address:

>>> fake_factory('email').example()

>>> 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. 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.


hypothesis.extra.numpy adds support for testing your Numpy code with Hypothesis.

This includes generating arrays, array shapes, and both scalar or compound dtypes.

Like the Django extra, Numpy has it’s own page.