Hi,

as far as I understood the patch would start and stop a server on each TestCase 
written in Python.

Since I want to run selenium test not via Remote Control, but with 
Selenium-Core direct thru the web-server I need a running test instance with 
well defined data.

I started to implement a runtestserver command for django/core/management.py as 
in the attached patch.

My first problem I stumble over is that the create_test_db is called twice and 
afterwards destroy_test_db is called twice.

Can anybody explain this ?

Regards,
Dirk
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Index: management.py
===================================================================
--- management.py	(Revision 5422)
+++ management.py	(Arbeitskopie)
@@ -1158,6 +1158,19 @@
         sys.stderr.write(s.read())
         sys.exit(1)
 
+def runtestserver(addr, port, use_reloader=True, admin_media_dir=''):
+	"Starts a lightweight Web server for testing."
+	from django.test.utils import setup_test_environment, teardown_test_environment
+	from django.test.utils import create_test_db, destroy_test_db
+	from django.conf import settings
+	setup_test_environment()
+	old_name = settings.DATABASE_NAME
+	create_test_db()
+	runserver(addr, port, use_reloader, admin_media_dir)
+	destroy_test_db(old_name)
+	teardown_test_environment()
+runtestserver.args = '[--noreload] [--adminmedia=ADMIN_MEDIA_PATH] [optional port number, or ipaddr:port]'
+
 def runserver(addr, port, use_reloader=True, admin_media_dir=''):
     "Starts a lightweight Web server for development."
     from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException
@@ -1468,6 +1481,7 @@
     'reset': reset,
     'runfcgi': runfcgi,
     'runserver': runserver,
+    'run2server': runtestserver,
     'shell': run_shell,
     'sql': get_sql_create,
     'sqlall': get_sql_all,
@@ -1603,7 +1617,7 @@
         except IndexError:
             parser.print_usage_and_exit()
         action_mapping[action](name, os.getcwd())
-    elif action == 'runserver':
+    elif action in ('runserver', 'run2server'):
         if len(args) < 2:
             addr = ''
             port = '8000'

Reply via email to