We had a hunch that an un-mocked network call was taking 3 seconds to time out. I patched this call throughout the test code base. It turns out this did not have a significant effect on the runtime of our tests, but it's good to mock out network calls anyway, even if they fail fast.

I ran a profiler on the code. Well that's not true, I just timed various parts of the code to see how long they took, using some code like this:

import datetime start = datetime.datetime.now() some_expensive_call() total = (datetime.datetime.now() - start).total_seconds() print "some_expensive_call took {} seconds".format(total)

It took about ten minutes to zero in on the fixture loader, which was doing something like this:

def load_fixture(fixture): model = find_fixture_in_db(fixture['id']) if not model: create_model(**fixture) else: update_model(model, fixture)

The call to find_fixture_in_db was doing a "full table scan" of our SQLite database, and taking about half of the run-time of the integration tests. Moreover in our case it was completely unnecessary, as we were deleting and re-inserting everything with every test run.

I added a flag to the fixture loader to skip the database lookup if we were doing all inserts. This sped up observed test time by about 35%.