Re: Unittest test-database not empty
Hi rock, I had the same problem and traced it to one of the contrib.auth tests. It seems they don't delete two of the testusers there. I added a ticket about it (http://code.djangoproject.com/ticket/6923), and will just use another username for my own tests meanwhile. /Emil On 30 Jan, 10:34, rock <[EMAIL PROTECTED]> wrote: > I have no fixtures/initial_data-files anywhere in my project tree! > Actually, the only file named "initial_data" on my system is djtrunk/ > tests/modeltests/fixtures/fixtures/initial_data.json. And that file > doesn't contain much. > > The "ghost-users" only show up when I'm running "./manage.py test". > When I delete the project database and run "./manage.py syncdb" and "./ > manage.py runserver" an empty database is created. So I guess my > problem has something to do with the unittesting, but it is still > magic to me how and when these users are created. > > Best regards, > Stein --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Unittest test-database not empty
I have no fixtures/initial_data-files anywhere in my project tree! Actually, the only file named "initial_data" on my system is djtrunk/ tests/modeltests/fixtures/fixtures/initial_data.json. And that file doesn't contain much. The "ghost-users" only show up when I'm running "./manage.py test". When I delete the project database and run "./manage.py syncdb" and "./ manage.py runserver" an empty database is created. So I guess my problem has something to do with the unittesting, but it is still magic to me how and when these users are created. Best regards, Stein --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Unittest test-database not empty
On Jan 30, 2008 5:36 AM, rock <[EMAIL PROTECTED]> wrote: > > Thanks Russ, for your helpful comments! > > I'm now searching for the initial_data fixture. I have looked through > all files in this project without success. When I run > > python manage.py test > > there is no such sentence as "Loading 'initial_data' fixtures", but > maybe there shouldn't be one? I've also looked in all files named > initial_data.* on my system without luck. You won't see any loading messages during the test run; you only see that message when you syncdb, or if you manually call 'loaddata initial_data' > I have a vague memory of creating these users (testuser and testuser2) > a long time ago, possibly under another project. Does anybody know how > to find (or delete) this fixture that is hiding somewhere? Crank up the verbosity - pass in -v 2 as an argument to ./manage.py loaddata, and it will tell you every location that it is checking for fixtures, and what it finds there. 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 -~--~~~~--~~--~--~---
Re: Unittest test-database not empty
Thanks Russ, for your helpful comments! I'm now searching for the initial_data fixture. I have looked through all files in this project without success. When I run python manage.py test there is no such sentence as "Loading 'initial_data' fixtures", but maybe there shouldn't be one? I've also looked in all files named initial_data.* on my system without luck. I have a vague memory of creating these users (testuser and testuser2) a long time ago, possibly under another project. Does anybody know how to find (or delete) this fixture that is hiding somewhere? Best regards, Stein --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Unittest test-database not empty
On Jan 29, 2008 4:27 AM, rock <[EMAIL PROTECTED]> wrote: > > I'm using the unittesting-environment for test-driven-development in > Django. It works excellent, but one matter is puzzling. The Django > documentation tells me this: > > "The test database > Tests that require a database (namely, model tests) will not use your > "real" (production) database. A separate, blank database is created > for the tests." ... > When I print the usernames of these users, they are "testuser" and > "testuser2". I expect one of two explanations; either I am doing > something strange, or the Django-documentation for "Testing Django > Applications" is not correct. This is a slightly misleading statement in the test documentation. 'Blank' is perhaps not the best word here. At the start of each test, t0he database is returned to the initial state - that is, the state it was in just after syncdb was called. This means that the only data in the database will be the data defined in an initial_data fixture. In your case, this means you have a testuser and testuser2 in an initial_data fixture somewhere in your project. This is mentioned in the testing docs, but not in the section you refer to. This could definitely be improved. Feel free to open a ticket for this issue. Yours, Russ Magee %-) 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 -~--~~~~--~~--~--~---
Unittest test-database not empty
I'm using the unittesting-environment for test-driven-development in Django. It works excellent, but one matter is puzzling. The Django documentation tells me this: "The test database Tests that require a database (namely, model tests) will not use your "real" (production) database. A separate, blank database is created for the tests." However, the test database is not empty after creation, it has two users, which makes my test fail: class MyselfTest(unittest.TestCase): def testNoInitialUsers(self): all_users = User.objects.all() self.assertEqual(0, len(all_users)) The test fails with the message: AssertionError: 0 != 2 When I print the usernames of these users, they are "testuser" and "testuser2". I expect one of two explanations; either I am doing something strange, or the Django-documentation for "Testing Django Applications" is not correct. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---