Skip to content
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

SimpleTestCase triggers database migrations #1049

Open
flaeppe opened this issue Mar 6, 2023 · 1 comment · May be fixed by #1120
Open

SimpleTestCase triggers database migrations #1049

flaeppe opened this issue Mar 6, 2023 · 1 comment · May be fixed by #1120

Comments

@flaeppe
Copy link

flaeppe commented Mar 6, 2023

The default implementation of SimpleTestCase disables database queries per default, which is why I'm thinking that migrating the database could conditionally happen depending on the value of SimpleTestCase.databases?

SimpleTestCase disallows database queries by default. This helps to avoid executing write queries which will affect other tests since each SimpleTestCase test isn’t run in a transaction. If you aren’t concerned about this problem, you can disable this behavior by setting the databases class attribute to 'all' on your test class.

Ref: https://docs.djangoproject.com/en/4.1/topics/testing/tools/#django.test.SimpleTestCase.databases

@marianobianchi
Copy link

I'm having the same issue. It will be great to have this fixed because sometimes the difference in testing times between pytest and django tests are big because of this (i.e: django tests take 80s to finish and pytest tests take 145s)

@flaeppe flaeppe linked a pull request Apr 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants