"setup_test_environment()<https://docs.djangoproject.com/en/1.6/topics/testing/advanced/#django.test.utils.setup_test_environment>
installs
a template renderer which will allow us to examine some additional
attributes on responses such as response.context that otherwise wouldn't be
available. Note that this method *does not* setup a test database, so the
following will be run against the existing database and the output may
differ slightly depending on what polls you already created."

That's from the section you linked to, and it clearly explains that a test
database will not be created. Two sections below that is
https://docs.djangoproject.com/en/1.6/intro/tutorial05/#testing-our-new-viewwhich
demonstrates how to create test cases that inherit from TestCase that
can be found and executed by the Django test runner which will also handle
creating the test database for you.

JDB


On Thu, Feb 13, 2014 at 10:20 AM, Paul Sermon <paulser...@googlemail.com>wrote:

> yes I am running through the manage.py shell (although initially I did
> not).
>
> I am doing the section:
> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#the-django-test-client
> On the response.content line, I get back a line listing the polls made
> earlier.
>
> And I presume that is why the test from the next section fail, because
> they are picking up the entries from the database, rather than the test
> database.
>
> I am on windows 7, if that makes any difference.
>
>
>
>
> On Thursday, February 13, 2014 2:58:37 PM UTC, jondbaker wrote:
>
>> Are you running your tests on the command line using:
>>
>> $ python manage.py test polls
>>
>> ...or are you trying to run them from a Python shell? It'd be helpful if
>> you could provide the internal link to the area of the page you linked to
>> that you're experiencing the failure at, as well as the output of the error
>> you're receiving and the command that causes it.
>>
>> JDB
>>
>>
>> On Thu, Feb 13, 2014 at 3:19 AM, Paul Sermon <pauls...@googlemail.com>wrote:
>>
>>> This is the tutorial: https://docs.djangoproject.com/en/1.6/
>>> intro/tutorial05/
>>>
>>> I've followed the tutorials pretty much to the letter since tutorial one.
>>>
>>> Thanks for the help!
>>>
>>> -Paul
>>>
>>>
>>> On Wednesday, February 12, 2014 10:33:16 PM UTC, jondbaker wrote:
>>>
>>>> You're correct in thinking that tests use a test database that is
>>>> independent of your formally defined project database. Without knowing
>>>> exactly which Django tutorials you are referring to, I can only assume that
>>>> perhaps you:
>>>>
>>>> 1) Have defined initial_data.json fixtures
>>>> 2) Have defined other fixtures that your tests are referencing (likely
>>>> in their setUp method)
>>>>
>>>> If none of the items above are correct, feel free to provide a link to
>>>> the tutorial you're going through and I'll take a look.
>>>>
>>>> JDB
>>>>
>>>>
>>>> On Wed, Feb 12, 2014 at 2:33 PM, Paul Sermon 
>>>> <pauls...@googlemail.com>wrote:
>>>>
>>>>> So I'm working my way through the Django tutorials, and have got as
>>>>> far as the view tests.  It seems that when running the test client, rather
>>>>> than returning data from an empty test database (is this what is meant to
>>>>> happen?) it is returning polls from the existing database, which has the
>>>>> polls created in the previous tutorials.  This means the tests that expect
>>>>> empty result sets fail.
>>>>>
>>>>> Any idea why it would be doing this?  Am I correct in thinking the
>>>>> test should create it's own empty database to test this?
>>>>>
>>>>> --
>>>>> 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 http://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/django-users/e1782c5f-d8e7-4fc6-93d8-88d01aafbd4f%40goog
>>>>> legroups.com.
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>   --
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/4031d95b-7f80-4839-a25a-800649e33cf1%
>>> 40googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Jonathan D. Baker
>> Developer
>> http://jonathandbaker.com
>>
>  --
> 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+unsubscr...@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/0d1f956e-3ba2-4737-a33f-a6dc4610542a%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
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+unsubscr...@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/CAPMFOb5cRbsOs%2BnctsWOXc-eiRErGMorhqodS1zKpu%2BmSoRr7A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to