Re: Django v1.2 TestCase doesn't seem to load fixtures except 'initial_data'
On Thu, May 27, 2010 at 3:34 PM, Bryan wrote: > just checked this again. > > 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'... > <> > No fixtures found. > > I don't know why this is happening, but it is. :-( > All I can say is it's working for me, really, and I honestly expect if this were in fact broken in general we'd have heard a lot more about it than a single report. Also, the "No fixtures found" just means no initial data fixtures were found. I get the "No fixtures found" for my working test run that requires a fixture file to be successfully loaded. As I tried to note in my previous response, the feedback related to loading non-initial-data fixtures in the test runner is poor. Near as I can tell it is nonexistent. (There's likely a good reason for that -- these things are loaded for each and every test method in the test case, so any output would potentially be repeated many many times. I've not looked at this code in any detail yet to see if an error situation with a fixture not being found can reasonably be reported.) What happens if you change your settings file to point to a temporary/test DB and try manage.py loaddata for this fixture? The output there should tell you whether any fixture with that name is found, and if so, how many objects were loaded from it. Further, you could actually then check the DB to see if what was loaded is what you (and your test) are expecting. 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.
Re: Django v1.2 TestCase doesn't seem to load fixtures except 'initial_data'
I just checked this again. 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'... <> No fixtures found. I don't know why this is happening, but it is. :-( Bryan On May 27, 8:33 am, Karen Tracey wrote: > On Wed, May 26, 2010 at 4:28 PM, Bryan 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 '}) > > > 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.
Re: Django v1.2 TestCase doesn't seem to load fixtures except 'initial_data'
On Wed, May 26, 2010 at 4:28 PM, Bryan 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 '}) > > 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.
Django v1.2 TestCase doesn't seem to load fixtures except 'initial_data'
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'}) 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. -- 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.