Pre-compile fixtures for unit tests.

Review Request #4564 — Created Sept. 13, 2013 and submitted

Information

Review Board
master

Reviewers

Pre-compile fixtures for unit tests.

Django's fixture support is extraordinarily inefficient. For every
single unit test, it does the following:

  • Recalculates the list of possible fixture directories
  • Locates each fixture file within those directories
  • Tries to figure out how to deserialize them
  • Deserializes them
  • Saves them

That's done per-test. Most of those operations are things that could be
easily cached, including the deserialized fixture content.

Our TestCase rewrites fixture loading to do just this. When we see a new
fixture, we precompile it, getting the list of objects and storing it.
We then use that precompiled version whenever the fixture is requested
for future tests.

This saves 10 seconds on the test suite.

Ran 746 tests in 80.604s

reviewbot
  1. This is a review from Review Bot.
    Tool: PEP8 Style Checker
    Processed Files:
    reviewboard/testing/testcase.py
    reviewboard/scmtools/tests.py
    reviewboard/reviews/tests.py
    reviewboard/diffviewer/tests.py
    reviewboard/hostingsvcs/tests.py
    Ignored Files:
    reviewboard/scmtools/fixtures/test_site.json

  2. 
      
reviewbot
  1. This is a review from Review Bot.
    Tool: Pyflakes
    Processed Files:
    reviewboard/testing/testcase.py
    reviewboard/scmtools/tests.py
    reviewboard/reviews/tests.py
    reviewboard/diffviewer/tests.py
    reviewboard/hostingsvcs/tests.py
    Ignored Files:
    reviewboard/scmtools/fixtures/test_site.json

  2. 
      
david
  1. Ship It!

  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Loading...