#36429: IntegrityError on contentype creation when using transactional test with
AND without serialized_rollback
-----------------------------------+------------------------------------
Reporter: Julie Rymer | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Comment (by Julie Rymer):
Also for those affected, I found a workaround I'm using with pytest.
You can use the `pytest_collection_modifyitems` hook to change the order
of the tests and have all transactional tests with
`serialized_rollback=False` all run at the end. This way the post_migrate
won't affect any test with `serialized_rollback=True`.
{{{
def pytest_collection_modifyitems(config, items):
def transactional_attr_order(item):
marker = item.get_closest_marker("django_db")
if (
marker
and marker.kwargs.get("transaction", False)
and not marker.kwargs.get("serialized_rollback", False)
):
return 1
return 0
items.sort(key=transactional_attr_order)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36429#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019735117ae9-1031a45e-7e6a-4349-b71d-2f58d6de29a4-000000%40eu-central-1.amazonses.com.