1. Chris Lee-Messer
  2. django-wsgiserver


Chris Lee-Messer  committed 49744a7

mostly work experimenting with unittest

  • Participants
  • Parent commits 79ba12b
  • Branches default

Comments (0)

Files changed (2)

File django_wsgiserver/management/commands/runwsgiserver.py

View file
   adminserve=True|False  Deprecated. Has no effect. The admin is served if
                          staticserve is active.
+  autoreload=True|False  reload the code if it changes. defaults to True
   Run a "standard" CherryPy wsgi server--good for local development

File tests/test_project.py

View file
 # my view uses RequestContext to render the template
 import requests, sys, os, time
-import subprocess
+import subprocess, StringIO
 import unittest
 PIDFILE = os.path.join(os.getcwd(),'test_project.pid')
-def launch_project():
+def launch_project_developer_mode():
+    """start django wsgiserver as daemon in developer mode"""
+    print "hello from launch project developer mode"
+    #sout = StringIO.StringIO()
+    #serr = StringIO.StringIO()
+    try:
+        subprocess.check_call(["python", r"testdjangoproject/testdjango/manage.py",
+            "runwsgiserver",
+            "threads=10", "daemonize",
+            "pidfile=%s" % PIDFILE])
+    except subprocess.CalledProcessError, msg:
+        print msg
+def launch_project_production_mode():
     """start django wsgiserver as daemon"""
-    print "hello from launch project"
-    subprocess.call(["python", r"testdjangoproject/testdjango/manage.py",
+    print "hello from launch project production mode"
+    subprocess.check_call(["python", r"testdjangoproject/testdjango/manage.py",
+                     "staticserve=False",
+                     "autoreload=False",
                      "threads=10", "daemonize",
                      "pidfile=%s" % PIDFILE])
 def stop_project():
     print "olleh from stop project"
 class TestDeveloperMode(unittest.TestCase):
     def setUp(self):
-        launch_project()
+        launch_project_developer_mode()
         time.sleep(1) # it takes a little time for the server to get started
         self.session = requests.Session()
         self.ajaxurl = r'http://localhost:8000/testajax/' # remember it needs to end in a slash
+    def tearDown(self):
+        stop_project()
     def test_django_root(self):
         r = self.session.get(r'http://localhost:8000/')
-    def tearDown(self):
-        stop_project()
 def main():
-        launch_project()
+        launch_project_developer_mode()
         print "started project"