On Wed, May 26, 2010 at 4:28 PM, Bryan <bryan.wheel...@gmail.com> wrote:

> I am using Django v1.2
>
> The fixture I defined "forum_fixtures.json" don't seem to be loading
> when I run tests.
>
> from django.test.client import Client
> from django.test import TestCase
> from utils import *
> from forum.models import *
> from forum import auth
> from django.contrib.contenttypes.models import ContentType
>
>
> class UserProfileTestCases(TestCase):
>    """These are tests to verify that refactoring of UserProfile is
> correct"""
>    fixtures = ['forum_fixtures.json'] ## @ forum/fixtures/
> forum_fixtures.json
>    def setUp(self):
>        self.client = Client()
>        if self.client.login(username='DickCheney', password='test'):
>            print "client.login DickCheney successful";
>        else:
>            print "client.login FAILED"
>
>    def test_set_new_email(self):
>        orig_email = User.objects.get(username='DickCheney')
>        response = self.client.post('changeemail',
> {u'email':'cockgobb...@nwo.gov <u%27email%27%3a%27cockgobb...@nwo.gov>'})
>
> self.assertNotEqual(User.objects.get(username='DickCheney').email,
> orig_email)
>
> I ran the tests verbosely:
> python manage.py test --verbosity=2
>
> Django only looked for fixtures named 'initial_data'. Not once was
> there are search for 'forum_fixtures.json'
>
> I changed the fixture name to 'initial_data.json' and it now works.
>
> I just thought I'd post the work around.
>

Loading of non-initial-data fixtures during testing does work in 1.2. I've
just confirmed it with one of my own projects. If this did not work I'd
expect we'd quickly hear of it from multiple sources and I'm pretty sure a
number of Django's own tests would fail.

Diagnostics for the case where a file specified in a TestCase fixtures
attribute is not found are poor. If I change the name of my test fixture
file on disk without changing the test that refers to it, there is nothing
in the test output, even at verbosity 2, other than errors from the failing
tests cases that require the fixture, to indicate the problem. There is
exhaustive output regarding trying to load initial_data fixtures, but
nothing for the fixtures specified on an individual test case. I thought
there had been a ticket that addressed this fairly late in the 1.2 cycle but
I must be mis-remembering because I don't see any better diagnostics here
with 1.2 than I did with earlier versions.

Are you absolutely sure the name of the file on disk matched what you had
listed in the TestCase fixtures line?

Karen
-- 
http://tracey.org/kmt/

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

Reply via email to