However when you're running like mad you do probably keep changing what fields are in your models. This is 100% double plus true if you are running to keep up with a larger team of programmers who need your tool to configure their rapidly evolving applications.
And if you're running properly, you have a bunch of test fixture files which hold useful test data which probably won't even load when you're finished with today's changes.
You can hand-edit the fixtures, or write scripts to edit the fixtures, and I got pretty good at that. But sometimes you're adding new relations which are tricky enough that it the best tool to make a test fixture is the application you're already building. The trick is a simple two-stage process.
- When you add your new fields, you want to make them blank=True and null=True.
- Zero your database, load your old test fixture, which will load fine because it has no data and you demand none.
- Run around your test data doing the setup you need.
- Export your test data again.
- Go back to your models and remove the blank and null arguments.
- Now your models are as you want them, and your test data will load.
No comments:
Post a Comment