问题
I have a django test suite that builds a DB from a 400 line fixture file. It runs unfortunately slow. Several seconds per test.
I was on the train yesterday developing without internet access, with my wifi turned off, and I noticed my tests ran literally 10x faster without internet. And they are definitely running correctly.
Everything is local, it all runs fine without an internet connection. The tests themselves do not hit any APIs or make any other connections, so it seems it must be something else.
回答1:
This most likely means you've got some component installed which is trying to make network connections. Possibly something that does monitoring or statistics gathering?
The simplest way to figure out what's going on is to use tcpdump to capture your network traffic and see what's going on. To do that:
- Run
tcpdump -i any
(ortcpdump -i en1
if you're on a mac; the airport is usuallyen1
, but you can double check withifconfig
) - Watch the traffic to get some idea what's normal
- Run your test suite
- Watch the traffic printed by
tcpdump
to see if anything obviously jumps out at you
来源:https://stackoverflow.com/questions/28864152/django-tests-run-faster-with-no-internet-connection