Closed geoffrey-eisenbarth closed 1 month ago
Thanks for this. I'm bumping our tests to run against 5.1 too.
Would you mind adding your MockObject trick yet too? I suspect it will then pass the tests and we can merge.
Would you mind adding your MockObject trick yet too? I suspect it will then pass the tests and we can merge.
Is there a straightforward way to use the original MockObject (with index_together
) when testing against Django < 5.1 and use a different object (with model.Index
) for >= 5.1?
Or should we just update MockObject to use model.Index
(which would pass on earlier versions of Django, but not cover the situation where index_together
is actually used).
Could this help you do the first?
import django django.get_version()
It's not the cleanest, imo, since we have to override models.Model.__init__()
, but I think that's necessary until you decide to drop support for Django < 5.1.
Fixes #198. Passed tests both for Django 4.2.14 and 5.1.1 (with the additional change that
MockObject.Meta.index_together
is replaced withmodel.Index(fields=["name", "number"])
).