I have a large project where the serialize_db_to_string function from Django takes around 5s on every call to pytest. This DB has some pre-loaded fixtures so it doesn't start the test run empty.
The relevant Django code is:
https://github.com/django/django/blob/02a5cbfe76382da2a0414df17017185be5bd47f9/django/test/utils.py#L231-L239
This is called from pytest-django django_db_setup session fixture:
|
db_cfg = setup_databases( |
|
verbosity=request.config.option.verbose, |
|
interactive=False, |
|
**setup_databases_args, |
|
) |
We don't pass any of the serialize parameters so it defaults to serializing.
The Django DiscoverRunner doesn't always serialize:
https://github.com/django/django/blob/02a5cbfe76382da2a0414df17017185be5bd47f9/django/test/runner.py#L1081-L1089
It only serializes if there are any tests in the suite which use serialized_rollback:
https://github.com/django/django/blob/02a5cbfe76382da2a0414df17017185be5bd47f9/django/test/runner.py#L1044-L1056
We should try to do the same if possible.
I have a large project where the
serialize_db_to_stringfunction from Django takes around 5s on every call topytest. This DB has some pre-loaded fixtures so it doesn't start the test run empty.The relevant Django code is:
https://github.com/django/django/blob/02a5cbfe76382da2a0414df17017185be5bd47f9/django/test/utils.py#L231-L239
This is called from pytest-django
django_db_setupsession fixture:pytest-django/pytest_django/fixtures.py
Lines 144 to 148 in b732869
We don't pass any of the
serializeparameters so it defaults to serializing.The Django
DiscoverRunnerdoesn't always serialize:https://github.com/django/django/blob/02a5cbfe76382da2a0414df17017185be5bd47f9/django/test/runner.py#L1081-L1089
It only serializes if there are any tests in the suite which use
serialized_rollback:https://github.com/django/django/blob/02a5cbfe76382da2a0414df17017185be5bd47f9/django/test/runner.py#L1044-L1056
We should try to do the same if possible.