Skip to content

Disable file watching when running tests

Latest
Compare
Choose a tag to compare
@fozcode fozcode released this 07 Dec 17:05
· 5 commits to master since this release

A problem arose in 1.12 when running Django tests with MEDIA_DEV_MODE = True (which isn't recommended but can be handy for debugging). The test runner seems to repeatedly initialise the middleware without freeing up old instances, resulting in exhaustion of resources from all the watchdog instances after a certain number of tests.

This version disables filesystem watching when tests are running, by looking out for a TESTING setting. To add this setting and have it applied automatically when you run manage.py test, add the following to your Django settings.py:

import sys
TESTING = 'test' in sys.argv