Skip to content

Commit

Permalink
Добавил раннер для тестов
Browse files Browse the repository at this point in the history
  • Loading branch information
YraganTron committed May 31, 2017
1 parent d542b21 commit b345a67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/tests/runner.py
@@ -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/')
2 changes: 2 additions & 0 deletions project/settings.py
Expand Up @@ -104,6 +104,8 @@
},
]

TEST_RUNNER = 'core.tests.runner.TempMediaMixin'


# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
Expand Down

0 comments on commit b345a67

Please sign in to comment.