Tay Ray Chuan home archive

improving performance of django tests with yaml-based fixtures

Fri, 11 Jun 2010 23:43:44 +0800 | Filed under django

For TestCases that use yaml fixtures, and/or if your app contains initial data fixtures, they'll get loaded and parsed for every test method - yep, you read that right.

You can get a nice performance boost by caching parsed yaml fixtures/memoization.

Edit: Note that this won't kick in for non-file fixtures, like StringIO, which django.core.serializers.pyyaml might use; generating a key for those escapes me. StringIO works fine - Python does support really curious keys.

blog comments powered by Disqus