-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error importing Django, even when test doesn't use Django #1167
Comments
|
You haven't configured the Regardless, it's not a Hypothesis bug so I hope that helps 😞 |
|
The weird thing is that there is no Django used in this project at all. I have a Python package which uses pytest and other Python packages for blackbox testing of a remote system. I added Hypothesis tests to this package. (Right now I use unittest as test runner of the Hypothesis tests only because I am not sure about the compatibility of the pytest fixtures and hypothesis yet.) |
|
@fkromer It looks to me like this really is happening because you have Django installed but not properly configured, as @Zac-HD said. You can work around it by either getting rid of Django from your virtual environment (seems like a good idea if it's not used in this project!) or configuring it correctly. (I'm not saying it's not a bug. Indeed it seems possible we should consider this one, and thanks for reporting! Just suggesting a way out for you.) It's coming from here: https://github.com/HypothesisWorks/hypothesis-python/blob/eb8da64f29991e2d557c079a53b33f30446e7e19/src/hypothesis/internal/compat.py#L530, where we import django stuff to check if your test case is a django test case. Unfortunate that importing that gives us an exception that isn't |
|
@Zac-HD I think I want to reopen this, since really it would be better if our attempt to import Django didn't break us when the test doesn't want to use Django at all (in the non- I know you do the most to keep our issues organized, so I'm happy to be overridden (especially if you have time to explain, but even if not). I'm waffling between |
|
Aahhhhh, I see the problem now. Thanks for investigating and reopening this @dchudz, I'll post a fix later today. |
You can definitely use Pytest and Hypothesis; just don't use function fixtures and |
Even this is fine really, depending on what you're doing with function fixtures. It's only a problem if you need set up/tear down per example. |
If created a hypothesis test like follows:
If I run the test case with unittest I get an error which seem to relate to the Django test runner.
Have I missed something or is there some issue with the Django integration?
The text was updated successfully, but these errors were encountered: