Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d542b21
commit b345a67
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
import shutil | ||
|
||
from django.test.runner import DiscoverRunner | ||
from django.conf import settings | ||
|
||
|
||
class TempMediaMixin(DiscoverRunner): | ||
|
||
def setup_test_environment(self, **kwargs): | ||
super(TempMediaMixin, self).setup_test_environment() | ||
settings._original_media_root = settings.MEDIA_ROOT | ||
self._temp_media = '/tmp/test/' | ||
settings.MEDIA_ROOT = self._temp_media | ||
|
||
def teardown_test_environment(self, **kwargs): | ||
if os.path.exists('/tmp/test/'): | ||
shutil.rmtree('/tmp/test/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters