Thursday, January 29, 2015

Re: Forms test run on development database instead of test database

Thank you for the explanation. So I suppose a better way to do it whould be to provide initialize the choices in the DomainForm __init__?


Le mardi 27 janvier 2015 21:58:56 UTC+1, Collin Anderson a écrit :
Hi,

I just tried out your project. Looking at the stacktrace, the test module is importing forms (before the test starts). The forms module is running a query on startup for choices.

Don't do queries on startup. :)

Collin

On Monday, January 26, 2015 at 7:07:54 AM UTC-5, Merouane Atig wrote:
Hi,

I have a strange issue with a forms test and I would like to know if I'm doing something wrong or if it is a Django bug.

I created a repo to reproduce the issue I have: https://github.com/merwan/django-choicefield

I have a DomainForm class with a choice field populated from a table in the database. I'm trying to test it using the Django testing tools, but I get the error "django.db.utils.OperationalError: no such table: myapp_topleveldomain" (see the README in the Github repo for the full stack trace).

If I first create my development database and migrate it, then I do not have any error. I expected that the test would run on the test database but it is not the case.

My test environment should work properly as I also created a model test which runs correctly on the test database and do not need the development database.

Can you tell me what would be the proper way to write this test so that it runs on the test database? Is it a bug with the Django testing tools or am I doing something wrong when populating my ChoiceField?

I'm using Django 1.7.3 and Python 3.4.0

Thanks for your help

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a072f9cd-9db7-4465-93c1-ca54482d08cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment