#7835: Provide the ability for model definitions that are only availably during
testing
-------------------------------------+-------------------------------------
Reporter: Russell Keith-Magee | Owner: Josh
| Thomas
Type: New feature | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: feature test models | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
@HarryKane, sorry I missed your comment
> Could you elaborate on how to manually create the migration for the test
model?
I had to manually create the migration files myself. Since the models are
only auto-discovered during tests it's kind of painful to ''trick'' the
migration system in creating the migration itself; you need to perform
test auto-discovery before running `makemigrations`. Maybe it can be a
limitation of the solution at first?
@Josh Thomas
> Any idea what would be needed for this to make it in to Django proper?
Since no other solution emerged for that long I'd suggest creating a PR
with the above solution available from `django.test` and documenting its
usage. I've used it with success in many projects and I've been wanting to
create third-party package that exposes it as well as a
`createtestmigrations` command that basically performs test discovery and
then delegates to `makemigrations` but I haven't been able to do so.
The challenge will likely be in writing tests for it. I guess we could
models defined in a specialzed test app that are discovered by the Django
test suite itself and that would be enough?
--
Ticket URL: <https://code.djangoproject.com/ticket/7835#comment:55>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/0107018d37d3d7cb-213943cd-1a89-4cb0-99e8-216c4c7747c3-000000%40eu-central-1.amazonses.com.