Skip to content

hypothesis.extra.django.TestCase vs. Django INSTALLED_APPS #3716

Closed
@erikrw

Description

@erikrw

Hello, I'm trying out Hypothesis 6.82.2 on my Django 4.2 project.

Importing hypothesis.extra.django.TestCase fails with "RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS."

The error is triggered by hypothesis/extra/django/_fields.py doing from django.contrib.auth.forms import UsernameField

It can be fixed by adding 'django.contrib.contenttypes' to the INSTALLED_APPS setting.

However, I would like to use Hypothesis without modifying my INSTALLED_APPS setting.

Ideally, Hypothesis should use UsernameField when it is available, and not register strategies for it when it is not available. UsernameField is available when 'django.contrib.contenttypes' and 'django.contrib.auth' are in INSTALLED_APPS, as far as I can tell.

Would you be open to such a change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementit's not broken, but we want it to be betterinterophow to play nicely with other packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions