I just did this for the first time last night, although I definitely don't know how to write good tests, at least I wrote some tests.
First thing you'll wanna check out if you haven't is: http://www.djangoproject.com/documentation/testing/ But I assume you have, so I'll just get on to the fixtures. Probably the easiest way to create a fixture is to enter some data into your site from the admin interface. Then go to your project folder (the one with manage.py in it) and type something like: $>python manage.py dumpdata --indent=4 --format=json > my_text_fixture.json Both the --indent and --format flags are optional, I think the output is JSON by default. For more information on dumping data into a fixture, check out: http://www.djangoproject.com/documentation/django-admin/#dumpdata-appname-appname Then, when you write your unit tests for your app in tests.py, you simply load up that fixture at the beginning of each test case. The docs say that the test database is flushed and restored for each individual test case. Here's what one of my test cases looks like: class FormatTestCase(TestCase): fixtures = ['book/test_data/book_test_data.json'] def setUp(self): self.haiku = Submission.objects.get(title="A Peaceful Haiku") def testPermalink(self): self.assertEquals(self.haiku.get_absolute_url(), "/submission/ peaceful-haiku/") Hope that helps. Obviously, this only works for unit tests. I'm not entirely sure how you load fixtures for doctests, maybe someone more experienced would like to tackle that. On Apr 1, 12:31 pm, Tony <[EMAIL PROTECTED]> wrote: > I am relatively new to Django, and I am having trouble getting my head > around fixtures. > The Django documentation just assumes that you should know what a > test fixture is and how to write one. I understand that fixtures are > just test data, but how is one written? > > Any guidance/examples on this would be great. > > Thanks, > Tony --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---