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':'cockG...@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.
I changed the fixtures name to:
$ ls forum/fixtures
forum_fixtures.json
class UserProfileTestCases(TestCase):
"""These are tests to verify that refactoring of UserProfile is
correct"""
fixtures = ['forum_fixtures.json']
$ python manage.py test
Creating test database 'default'...
<<SNIP>>
No fixtures found.
I don't know why this is happening, but it is. :-(
Bryan
On May 27, 8:33 am, Karen Tracey <kmtra...@gmail.com> wrote:
> 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>'})
just checked this again.
I changed the fixtures name to:
$ ls forum/fixtures
forum_fixtures.json
$ python manage.py test
class UserProfileTestCases(TestCase):
"""These are tests to verify that refactoring of UserProfile is
correct"""
fixtures = ['forum_fixtures.json']
Creating test database 'default'...
<<SNIP>>
No fixtures found.
I don't know why this is happening, but it is. :-(