Discussion:
Cannot get Django test migrations to detect test models.py
c***@routh.io
6 years ago
Permalink
Hi folks, I'm trying to build a test suite for a django plugin for a field.
To test the field I need to have a test model, but since my django app does
not provide models, and I have the model in the /tests/models.py it's not
detecting the model when the test db migrations are applied. I saw some
suggestions on stack overflow to add the test app to the INSTALLED_APPS in
the test app, however that causes an
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. error,
which I imagine is caused by the tests app not being a full blown app.
What's the proper solution for Django 2.0+ ? I'd prefer not to use the fake
models solution as I plan to open source the module and want the field
tested against a real db on Django 2.0 and 2.1.

Source is here: https://gitlab.routh.io/open-source/django-bleachfields

Test failures and attempted configurations can be seen in the CI pipeline
and commit history.

Hoping someone can lend their insights.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d525bd73-0db8-4d17-b5b8-254461a9a533%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Phako Perez
6 years ago
Permalink
I can suggest to use different name for your test app, as directory test is used by Django for actual test your application, maybe is that the reason your app is failing

Sent from my iPhone
...
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C71D5DB6-C733-4265-9B4C-EE05CEC6ED52%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
c***@routh.io
6 years ago
Permalink
I am not sure you understood. I am doing testing, and this is a model that is only for tests. I am attempting to achieve the test-only models solution outlined here:

https://code.djangoproject.com/ticket/7835#comment:24

Also outlined in the first paragraph of this accepted answer on stack overflow:

https://stackoverflow.com/questions/502916/django-how-to-create-a-model-dynamically-just-for-testing?rq=1


app/tests/models.py or putting models in app/tests.py should result in the model being detected and migrated in the test database, but the model is never detected, so the tests fail when they are run because the tables are missing.


From: "Phako Perez" <***@gmail.com>
To: "django-users" <django-***@googlegroups.com>
Sent: Saturday, November 3, 2018 7:06:19 PM
Subject: Re: Cannot get Django test migrations to detect test models.py

I can suggest to use different name for your test app, as directory test is used by Django for actual test your application, maybe is that the reason your app is failing

Sent from my iPhone

On Nov 3, 2018, at 12:40 PM, [ mailto:***@routh.io | ***@routh.io ] wrote:




Hi folks, I'm trying to build a test suite for a django plugin for a field. To test the field I need to have a test model, but since my django app does not provide models, and I have the model in the /tests/models.py it's not detecting the model when the test db migrations are applied. I saw some suggestions on stack overflow to add the test app to the INSTALLED_APPS in the test app, however that causes an django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. error, which I imagine is caused by the tests app not being a full blown app. What's the proper solution for Django 2.0+ ? I'd prefer not to use the fake models solution as I plan to open source the module and want the field tested against a real db on Django 2.0 and 2.1.

Source is here: [ https://gitlab.routh.io/open-source/django-bleachfields | https://gitlab.routh.io/open-source/django-bleachfields ]

Test failures and attempted configurations can be seen in the CI pipeline and commit history.

Hoping someone can lend their insights.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [ mailto:django-users+***@googlegroups.com | django-users+***@googlegroups.com ] .
To post to this group, send email to [ mailto:django-***@googlegroups.com | django-***@googlegroups.com ] .
Visit this group at [ https://groups.google.com/group/django-users | https://groups.google.com/group/django-users ] .
To view this discussion on the web visit [ https://groups.google.com/d/msgid/django-users/d525bd73-0db8-4d17-b5b8-254461a9a533%40googlegroups.com?utm_medium=email&utm_source=footer | https://groups.google.com/d/msgid/django-users/d525bd73-0db8-4d17-b5b8-254461a9a533%40googlegroups.com ] .
For more options, visit [ https://groups.google.com/d/optout | https://groups.google.com/d/optout ] .
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [ mailto:django-users+***@googlegroups.com | django-users+***@googlegroups.com ] .
To post to this group, send email to [ mailto:django-***@googlegroups.com | django-***@googlegroups.com ] .
Visit this group at [ https://groups.google.com/group/django-users | https://groups.google.com/group/django-users ] .
To view this discussion on the web visit [ https://groups.google.com/d/msgid/django-users/C71D5DB6-C733-4265-9B4C-EE05CEC6ED52%40gmail.com?utm_medium=email&utm_source=footer | https://groups.google.com/d/msgid/django-users/C71D5DB6-C733-4265-9B4C-EE05CEC6ED52%40gmail.com ] .
For more options, visit [ https://groups.google.com/d/optout | https://groups.google.com/d/optout ] .
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1144431128.10508.1541425519599.JavaMail.zimbra%40routh.io.
For more options, visit https://groups.google.com/d/optout.
amit pant
6 years ago
Permalink
can you register your model in admin.py?
If not then go for it.
...
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF2Ah_E4d96VrDsnamQ1DJk9tzBgFG7EgpH7RNsEjKm-B-vG9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
c***@routh.io
6 years ago
Permalink
I'm not sure you understood the question.


From: "amit pant" <***@gmail.com>
To: "django-users" <django-***@googlegroups.com>
Sent: Monday, November 5, 2018 2:24:51 AM
Subject: Re: Cannot get Django test migrations to detect test models.py

can you register your model in admin.py?
If not then go for it.

On Sun 4 Nov, 2018, 12:10 AM , < [ mailto:***@routh.io | ***@routh.io ] > wrote:



Hi folks, I'm trying to build a test suite for a django plugin for a field. To test the field I need to have a test model, but since my django app does not provide models, and I have the model in the /tests/models.py it's not detecting the model when the test db migrations are applied. I saw some suggestions on stack overflow to add the test app to the INSTALLED_APPS in the test app, however that causes an django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. error, which I imagine is caused by the tests app not being a full blown app. What's the proper solution for Django 2.0+ ? I'd prefer not to use the fake models solution as I plan to open source the module and want the field tested against a real db on Django 2.0 and 2.1.

Source is here: [ https://gitlab.routh.io/open-source/django-bleachfields | https://gitlab.routh.io/open-source/django-bleachfields ]

Test failures and attempted configurations can be seen in the CI pipeline and commit history.

Hoping someone can lend their insights.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [ mailto:django-users+***@googlegroups.com | django-users+***@googlegroups.com ] .
To post to this group, send email to [ mailto:django-***@googlegroups.com | django-***@googlegroups.com ] .
Visit this group at [ https://groups.google.com/group/django-users | https://groups.google.com/group/django-users ] .
To view this discussion on the web visit [ https://groups.google.com/d/msgid/django-users/d525bd73-0db8-4d17-b5b8-254461a9a533%40googlegroups.com?utm_medium=email&utm_source=footer | https://groups.google.com/d/msgid/django-users/d525bd73-0db8-4d17-b5b8-254461a9a533%40googlegroups.com ] .
For more options, visit [ https://groups.google.com/d/optout | https://groups.google.com/d/optout ] .
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [ mailto:django-users+***@googlegroups.com | django-users+***@googlegroups.com ] .
To post to this group, send email to [ mailto:django-***@googlegroups.com | django-***@googlegroups.com ] .
Visit this group at [ https://groups.google.com/group/django-users | https://groups.google.com/group/django-users ] .
To view this discussion on the web visit [ https://groups.google.com/d/msgid/django-users/CAF2Ah_E4d96VrDsnamQ1DJk9tzBgFG7EgpH7RNsEjKm-B-vG9Q%40mail.gmail.com?utm_medium=email&utm_source=footer | https://groups.google.com/d/msgid/django-users/CAF2Ah_E4d96VrDsnamQ1DJk9tzBgFG7EgpH7RNsEjKm-B-vG9Q%40mail.gmail.com ] .
For more options, visit [ https://groups.google.com/d/optout | https://groups.google.com/d/optout ] .
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/368149463.10493.1541425347709.JavaMail.zimbra%40routh.io.
For more options, visit https://groups.google.com/d/optout.
Loading...