-
Notifications
You must be signed in to change notification settings - Fork 346
django-pytest raising DatabaseError in all tests #800
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
Comments
Can you make sure that it is related to pytest-django only, and then maybe git-bisect it? |
When I run manage.py test using Django's default test runner all tests passed. |
After multiple atempts I found that the problem is with pluggy requirement.
this error occurs.
All tests have passed. After this analysis think pytest-django should have a requirement for pytest>=3.6,<4. Hope this was helpfull |
No. If I keep pytest version<4 and pluggy==0.11 all tests pass
With this model:
And this test:
It fails with pluggy==0.12 and works with pluggy==0.11 |
I had the same problem and the same workaround worked for me. I was trying to test a Django 2.2.x app with pytest >= 4 (tried with 6.0.2) and pytest-django 3.10. But upgrading the app to Django 3.1 also resolved the issue, which is a better option than downgrading pytest. |
The above did not solve the issue for me. I now have:
and it still produces the above error. Upgrading Django may help, though it's pretty disappointing in general that a lot of packages seem not to set an upper bound on their dependencies, and thus their older versions simply break and become unusable. (A very similar bug happened to ipython a few weeks ago.) In this case it's even more disappointing since it means that this package does not support the current LTS version of django, which will be maintained for another year (and which happens to be the only LTS at the moment). Not that I'm that much keen on using an LTS version, but some people definitely are - LTS exists for a reason. |
... but what seems to work, as a temporary solution is providing module or even package names on the command line. Here is how it works for me... I have the following configuration in my pytest.ini:
(The last two line may or may not be influencing this behaviour.) Now if I run This works with the following requirements without any problem:
(I didn't pin pluggy, it's what gets installed with the above requirements as of now. But I've checked and it works with 0.12 too.) |
Hi,
I was using django-pytest version 3.3.2 and my tests using Django TestCase were running just fine.
Now I started a new project and decided do use the latest django-pytest version, but all my tests are raising an error related to the default database being created in one thread but used in another.
Python: 3.7.2+and 3.6.9
Django Version: 2.2.9 and 2.2
pytest Version: 5.3.2
pytest-django Version: 3.8.0
psycopg2-binary: 2.8.4 (I'm using Postgres)
pytest.ini:
The error:
The text was updated successfully, but these errors were encountered: