Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improved runtests

Added runtestserver
Added runshell
  • Loading branch information...
commit c48cd0e8b847b8e4ed948e7e1beed6433ec87ab0 1 parent a4ddb39
@ojii ojii authored
Showing with 85 additions and 2 deletions.
  1. +1 −1  .gitignore
  2. +26 −0 runshell.py
  3. +1 −1  runtests.py
  4. +57 −0 runtestserver.py
View
2  .gitignore
@@ -8,7 +8,7 @@ cms/django
.*
*.xml
/*env*/
-cms.sqlite
+*.sqlite
cms/media/cms_page_media/
cms/docs/build
example/run
View
26 runshell.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+from cms.test_utils.cli import configure
+from cms.test_utils.tmpdir import temp_dir
+import os
+import sys
+
+
+def main():
+ with temp_dir() as STATIC_ROOT:
+ with temp_dir() as MEDIA_ROOT:
+ configure(
+ ROOT_URLCONF='cms.test_utils.project.urls',
+ STATIC_ROOT=STATIC_ROOT,
+ MEDIA_ROOT=MEDIA_ROOT,
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'cmstestdb.sqlite',
+ }
+ }
+ )
+ from django.core.management import call_command
+ call_command('shell')
+
+if __name__ == '__main__':
+ main()
View
2  runtests.py 100644 → 100755
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
from cms.test_utils.cli import configure
from cms.test_utils.tmpdir import temp_dir
import argparse
@@ -17,7 +18,6 @@ def main():
parser.add_argument('--time-tests', action='store_true', default=False,
dest='time_tests')
args = parser.parse_args()
- args.urlconf = 'cms.test_utils.project.urls'
if getattr(args, 'jenkins', False):
TEST_RUNNER = 'cms.test_utils.runners.JenkinsTestRunner'
else:
View
57 runtestserver.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+from cms.test_utils.cli import configure
+from cms.test_utils.tmpdir import temp_dir
+import argparse
+import os
+import sys
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-p', '--port', default='8000')
+ parser.add_argument('-b', '--bind', default='127.0.0.1')
+ args = parser.parse_args()
+ new_db = not os.path.exists('cmstestdb.sqlite')
+ with temp_dir() as STATIC_ROOT:
+ with temp_dir() as MEDIA_ROOT:
+ configure(
+ ROOT_URLCONF='cms.test_utils.project.urls',
+ STATIC_ROOT=STATIC_ROOT,
+ MEDIA_ROOT=MEDIA_ROOT,
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'cmstestdb.sqlite',
+ }
+ }
+ )
+ from django.core.management import call_command
+ call_command('syncdb', interactive=False, migrate_all=new_db)
+ call_command('migrate', interactive=False, fake=new_db)
+ from django.contrib.auth.models import User
+ if not User.objects.filter(is_superuser=True).exists():
+ usr = User()
+ usr.username = 'admin'
+ usr.email = 'admin@admin.com'
+ usr.set_password('admin')
+ usr.is_superuser = True
+ usr.is_staff = True
+ usr.is_active = True
+ usr.save()
+ print
+ print "A admin user (username: admin, password: admin) has been created."
+ print
+ from django.contrib.staticfiles.management.commands import runserver
+ rs = runserver.Command()
+ rs.stdout = sys.stdout
+ rs.stderr = sys.stderr
+ rs.use_ipv6 = False
+ rs._raw_ipv6 = False
+ rs.addr = args.bind
+ rs.port = args.port
+ rs.inner_run(addrport='%s:%s' % (args.bind, args.port),
+ insecure_serving=True)
+
+
+if __name__ == '__main__':
+ main()
Please sign in to comment.
Something went wrong with that request. Please try again.