On Fri, Nov 7, 2008 at 1:00 AM, AndyH <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have the following simple test which demonstrates the confusing
> behaviour I'm seeing:
>
> class AvailabilityTestCase(django.test.TestCase):
>    fixtures = FIXTURE_LIST
>    def setUp(self):
>        response = self.client.login(username='testuser',
> password='password')
>        self.assertTrue(response)
>
>    def test_page(self):
>        print Calendar.objects.all()
>        print Calendar.objects.all()
>
>    def test_page_again(self):
>        print Calendar.objects.all()
>        print Calendar.objects.all()
>
> When I run this from "manage.py test", it prints out four lists of
> Calendars as expected. However, the second two, are slightly different
> to the first two. As far as I'm aware I'm not doing anything to the
> all() method (or subscribing in to any triggers) that might cause
> this. But even if I was, my understanding is that the fixtures are
> refreshed for each test so they can run independently of each other.
> In my case, which ever order I run these two tests the second set
> always prints different results to the first.

Assuming that FIXTURE_LIST is correctly defined and references well
formed fixtures, I can't see anything obviously wrong with your
example. You are correct in your understanding that a Django TestCase
will flush the database at the start of each test, so both tests
should have a clean database and be reporting the same results.

The suggestion that the GenericForeignKey is the source of the problem
is certainly plausible. I'm not aware of any problems serializing
Generic FK's, but they are more complicated and less exercised than
regular keys and fields, so it is certainly a reasonable place to
start looking.

If you could provide a minimal complete example of this behaviour and
attach it to a new ticket, it would be most helpful.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to