Speed up unit tests by about 15%.
Review Request #2575 — Created Sept. 3, 2011 and submitted — Latest diff uploaded
Speed up unit tests by about 15%. A large part of the reason unit tests take so long is the loading of the fixtures. Specifically, all the review request fixtures. However, many tests don't even need all the fixtures that their class loads. By making use of the new TestCase class and @add_fixtures decorator in Djblets, we can be more specific about what fixtures are used where. Several TestCase classes have been updated to only include the bare minimum set of fixtures defined in the class, with individual tests listing the other more specific fixtures they need. Through this and some other improvements, I've shaved over 30 seconds from my unit test run. That's a savings of about 15%. There's still more we can do here. The test_reviewrequests fixture is the biggest fixture, and most of what it contains should probably be split out. A good first step is to move all the site-specific ones out into another fixture. Without this, you need to include both test_reviewrequests and test_site in order to properly load in review requests to test with, even if we aren't testing with a site (since otherwise, those review requests come in with a local_site as None). We can also split out the review groups and changes into their own fixtures. Many tests are really testing against those and don't need the full list of review requests.
Ran the test suite several times and compared the speeds. It's greatly improving the test runs.