Hi,
I think it might be useful to define a variable (such as TESTS) in settings, which will only be True when running tests, and then Django will know we are running tests and act accordingly, for example save files in a different directory (such as TESTS_MEDIA_ROOT) and not in the default MEDIA_ROOT directory, and delete them after all the tests end. And other actions which should run only in tests or only not in tests.
If such a variable is defined, its default value should be of course False.
I already defined different settings files in Speedy Net, and set set django_settings.TESTS to True only in tests. Until recently it was possible to run tests with other settings such as development, when running tests locally, but now it's deliberately disabled (with two asserts in speedy/core/base/test/models.py) because I don't want tests to run with the production (or development) MEDIA_ROOT settings.
Also notice, I used django_settings.TESTS_MEDIA_ROOT instead of django_settings.MEDIA_ROOT in tearDownClass in the above file, to prevent deleting the production MEDIA_ROOT directory by accident if the tests will still run in production (although it can't because of the asserts above).
I will appreciate your feedback or comments.