Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

VIRTUALENV, F*** YEAH!

  • Loading branch information...
commit 1f88e199c667a91e45e9474d9a2fdd7ea36d50b2 1 parent 01e1f9a
@ojii ojii authored
View
5 cms/test_utils/cli.py
@@ -113,6 +113,11 @@ def configure(**extra):
'de':['fr', 'en'],
'en':['fr', 'de'],
},
+ CMS_SITE_LANGUAGES = {
+ 1:['en','de','fr','pt-BR'],
+ 2:['de','fr'],
+ 3:['nl'],
+ },
CMS_TEMPLATES = (
('col_two.html', gettext('two columns')),
('col_three.html', gettext('three columns')),
View
26 cms/test_utils/tmpdir.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+from contextlib import contextmanager
+from tempfile import mkdtemp
+import os
+import random
+import shutil
+import stat
+
+
+@contextmanager
+def temp_dir():
+ name = make_temp_dir()
+ yield name
+ shutil.rmtree(name)
+
+def make_temp_dir():
+ if os.path.exists('/dev/shm/'):
+ if os.stat('/dev/shm').st_mode & stat.S_IWGRP:
+ dirname = 'django-cms-tests-%s' % random.randint(1,1000000)
+ path = os.path.join('/dev/shm', dirname)
+ while os.path.exists(path):
+ dirname = 'django-cms-tests-%s' % random.randint(1,1000000)
+ path = os.path.join('/dev/shm', dirname)
+ os.mkdir(path)
+ return path
+ return mkdtemp()
View
2  cms/tests/apphooks.py
@@ -52,7 +52,7 @@ def test_implicit_apphooks(self):
Test implicit apphook loading with INSTALLED_APPS + cms_app.py
"""
- apps = ['project.sampleapp']
+ apps = ['cms.test_utils.project.sampleapp']
with SettingsOverride(INSTALLED_APPS=apps, ROOT_URLCONF='cms.test_utils.project.urls_for_apphook_tests'):
apphook_pool.clear()
hooks = apphook_pool.get_apphooks()
View
2  cms/tests/nonroot.py
@@ -10,7 +10,7 @@
class NonRootCase(CMSTestCase):
- urls = 'project.nonroot_urls'
+ urls = 'cms.test_utils.project.nonroot_urls'
def setUp(self):
with SettingsOverride(CMS_MODERATOR = False):
View
4 cms/tests/page.py
@@ -304,7 +304,7 @@ def test_add_placeholder(self):
url = page.get_absolute_url()
response = self.client.get(url)
self.assertEqual(200, response.status_code)
- path = os.path.join(settings.PROJECT_DIR, 'templates', 'add_placeholder.html')
+ path = os.path.join(settings.TEMPLATE_DIRS[0], 'add_placeholder.html')
f = open(path, 'r')
old = f.read()
f.close()
@@ -626,7 +626,7 @@ def test_public_home_page_replaced(self):
self.assertEqual(Page.objects.public().get_home().get_slug(), 'home')
class NoAdminPageTests(CMSTestCase):
- urls = 'project.noadmin_urls'
+ urls = 'cms.test_utils.project.noadmin_urls'
def setUp(self):
admin = 'django.contrib.admin'
View
2  cms/tests/placeholder.py
@@ -89,7 +89,7 @@ def test_fieldsets_requests(self):
self.assertEqual(response.status_code, 200)
def test_fieldsets(self):
- from project.placeholderapp import admin as __ # load admin
+ from cms.test_utils.project.placeholderapp import admin as __ # load admin
request = self.get_request('/')
admins = [
(Example1, 2),
View
4 cms/tests/views.py
@@ -11,11 +11,11 @@
APP_NAME = 'SampleApp'
-APP_MODULE = "project.sampleapp.cms_app"
+APP_MODULE = "cms.test_utils.project.sampleapp.cms_app"
class ViewTests(SettingsOverrideTestCase):
- urls = 'project.urls_for_apphook_tests'
+ urls = 'cms.test_utils.project.urls_for_apphook_tests'
settings_overrides = {'CMS_MODERATOR': False}
def setUp(self):
View
20 runtests.py
@@ -1,4 +1,5 @@
from cms.test_utils.cli import configure
+from cms.test_utils.tmpdir import temp_dir
import argparse
import sys
@@ -23,14 +24,17 @@ def main():
TEST_RUNNER = 'cms.test_utils.runners.NormalTestRunner'
JUNIT_OUTPUT_DIR = getattr(args, 'jenkins_data_dir', '.')
TIME_TESTS = getattr(args, 'time_tests', False)
- configure(TEST_RUNNER=TEST_RUNNER, JUNIT_OUTPUT_DIR=JUNIT_OUTPUT_DIR,
- TIME_TESTS=TIME_TESTS, ROOT_URLCONF='cms.test_utils.project.urls')
- from django.conf import settings
- from django.test.utils import get_runner
- TestRunner = get_runner(settings)
-
- test_runner = TestRunner(verbosity=args.verbosity, interactive=False, failfast=args.failfast)
- failures = test_runner.run_tests(['cms', 'menus'])
+ with temp_dir() as STATIC_ROOT:
+ with temp_dir() as MEDIA_ROOT:
+ configure(TEST_RUNNER=TEST_RUNNER, JUNIT_OUTPUT_DIR=JUNIT_OUTPUT_DIR,
+ TIME_TESTS=TIME_TESTS, ROOT_URLCONF='cms.test_utils.project.urls',
+ STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT)
+ from django.conf import settings
+ from django.test.utils import get_runner
+ TestRunner = get_runner(settings)
+
+ test_runner = TestRunner(verbosity=args.verbosity, interactive=False, failfast=args.failfast)
+ failures = test_runner.run_tests(['cms', 'menus'])
if failures:
sys.exit(bool(failures))
Please sign in to comment.
Something went wrong with that request. Please try again.