Permalink
Browse files

use unique temp folder for all temporary files

(so multiple instances of the test suite can be run in parallel)
  • Loading branch information...
1 parent 38fbecc commit cc743c69c54bdc547c065571bbc824a8e60e6642 @stefanfoulis stefanfoulis committed Jan 23, 2013
Showing with 30 additions and 27 deletions.
  1. +4 −3 filer/tests/admin.py
  2. +2 −2 filer/tests/models.py
  3. +2 −2 filer/tests/permissions.py
  4. +2 −2 filer/tests/tools.py
  5. +2 −2 filer/tests/utils.py
  6. +18 −16 runtests.py
View
7 filer/tests/admin.py
@@ -4,13 +4,15 @@
from django.core.urlresolvers import reverse
import django.core.files
from django.contrib.admin import helpers
+from django.conf import settings
from filer.models.filemodels import File
from filer.models.foldermodels import Folder
from filer.models.imagemodels import Image
from filer.models.clipboardmodels import Clipboard
from filer.models.virtualitems import FolderRoot
from filer.models import tools
+from filer.test_utils.tmpdir import temp_dir
from filer.tests.helpers import (create_superuser, create_folder_structure,
create_image)
@@ -83,8 +85,7 @@ def setUp(self):
self.client.login(username='admin', password='secret')
self.img = create_image()
self.image_name = 'test_file.jpg'
- self.filename = os.path.join(os.path.dirname(__file__),
- self.image_name)
+ self.filename = os.path.join(settings.FILE_UPLOAD_TEMP_DIR, self.image_name)
self.img.save(self.filename, 'JPEG')
def tearDown(self):
@@ -123,7 +124,7 @@ def setUp(self):
self.client.login(username='admin', password='secret')
self.img = create_image()
self.image_name = 'test_file.jpg'
- self.filename = os.path.join(os.path.dirname(__file__),
+ self.filename = os.path.join(settings.FILE_UPLOAD_TEMP_DIR,
self.image_name)
self.img.save(self.filename, 'JPEG')
self.create_src_and_dst_folders()
View
4 filer/tests/models.py
@@ -3,6 +3,7 @@
from django.forms.models import modelform_factory
from django.test import TestCase
from django.core.files import File as DjangoFile
+from django.conf import settings
from filer.models.foldermodels import Folder
from filer.models.imagemodels import Image
@@ -21,8 +22,7 @@ def setUp(self):
self.client.login(username='admin', password='secret')
self.img = create_image()
self.image_name = 'test_file.jpg'
- self.filename = os.path.join(os.path.dirname(__file__),
- self.image_name)
+ self.filename = os.path.join(settings.FILE_UPLOAD_TEMP_DIR, self.image_name)
self.img.save(self.filename, 'JPEG')
def tearDown(self):
View
4 filer/tests/permissions.py
@@ -6,6 +6,7 @@
from django.contrib.auth.models import User # NOQA
from django.contrib.auth.models import Group
from django.core.files import File as DjangoFile
+from django.conf import settings
from django.test.testcases import TestCase
from filer import settings as filer_settings
from filer.models.clipboardmodels import Clipboard
@@ -36,8 +37,7 @@ def setUp(self):
self.img = create_image()
self.image_name = 'test_file.jpg'
- self.filename = os.path.join(os.path.dirname(__file__),
- self.image_name)
+ self.filename = os.path.join(settings.FILE_UPLOAD_TEMP_DIR, self.image_name)
self.img.save(self.filename, 'JPEG')
self.file = DjangoFile(open(self.filename), name=self.image_name)
View
4 filer/tests/tools.py
@@ -1,6 +1,7 @@
#-*- coding: utf-8 -*-
from django.core.files import File as DjangoFile
from django.test.testcases import TestCase
+from django.conf import settings
from filer.models import tools
from filer.models.clipboardmodels import Clipboard
from filer.models.foldermodels import Folder
@@ -14,8 +15,7 @@ def setUp(self):
self.client.login(username='admin', password='secret')
self.img = create_image()
self.image_name = 'test_file.jpg'
- self.filename = os.path.join(os.path.dirname(__file__),
- self.image_name)
+ self.filename = os.path.join(settings.FILE_UPLOAD_TEMP_DIR, self.image_name)
self.img.save(self.filename, 'JPEG')
self.file = DjangoFile(open(self.filename), name=self.image_name)
View
4 filer/tests/utils.py
@@ -1,6 +1,7 @@
#-*- coding: utf-8 -*-
from django.core.files import File as DjangoFile
from django.test.testcases import TestCase
+from django.conf import settings
from filer.tests.helpers import create_image
from filer.utils.loader import load
from filer.utils.zip import unzip
@@ -44,8 +45,7 @@ class ZippingTestCase(TestCase):
def setUp(self):
self.img = create_image()
self.image_name = 'test_file.jpg'
- self.filename = os.path.join(os.path.dirname(__file__),
- self.image_name)
+ self.filename = os.path.join(settings.FILE_UPLOAD_TEMP_DIR, self.image_name)
self.img.save(self.filename, 'JPEG')
self.file = DjangoFile(open(self.filename), name=self.image_name)
View
34 runtests.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-from __future__ import with_statement
from filer.test_utils.cli import configure
from filer.test_utils.tmpdir import temp_dir
import argparse
@@ -13,20 +12,23 @@ def main(verbosity=1, failfast=False, test_labels=None):
test_labels = ['filer']
with temp_dir() as STATIC_ROOT:
with temp_dir() as MEDIA_ROOT:
- # from django import VERSION
- # use_tz = VERSION[:2] >= (1, 4)
- use_tz = False
- warnings.filterwarnings(
- 'error', r"DateTimeField received a naive datetime",
- RuntimeWarning, r'django\.db\.models\.fields')
- configure(ROOT_URLCONF='test_urls',
- STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT, USE_TZ=use_tz)
- from django.conf import settings
- from django.test.utils import get_runner
- TestRunner = get_runner(settings)
-
- test_runner = TestRunner(verbosity=verbosity, interactive=False, failfast=failfast)
- failures = test_runner.run_tests(test_labels)
+ with temp_dir() as FILE_UPLOAD_TEMP_DIR:
+ # from django import VERSION
+ # use_tz = VERSION[:2] >= (1, 4)
+ use_tz = False
+ warnings.filterwarnings(
+ 'error', r"DateTimeField received a naive datetime",
+ RuntimeWarning, r'django\.db\.models\.fields')
+ configure(
+ ROOT_URLCONF='test_urls',
+ STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT,
+ FILE_UPLOAD_TEMP_DIR=FILE_UPLOAD_TEMP_DIR,
+ USE_TZ=use_tz)
+ from django.conf import settings
+ from django.test.utils import get_runner
+ TestRunner = get_runner(settings)
+ test_runner = TestRunner(verbosity=verbosity, interactive=False, failfast=failfast)
+ failures = test_runner.run_tests(test_labels)
sys.exit(failures)
@@ -37,4 +39,4 @@ def main(verbosity=1, failfast=False, test_labels=None):
parser.add_argument('test_labels', nargs='*')
args = parser.parse_args()
test_labels = ['%s' % label for label in args.test_labels]
- main(verbosity=args.verbosity, failfast=args.failfast, test_labels=test_labels)
+ main(verbosity=args.verbosity, failfast=args.failfast, test_labels=test_labels)

0 comments on commit cc743c6

Please sign in to comment.