cleemesser committed 49744a7

mostly work experimenting with unittest

  • Participants
  • Parent commits 79ba12b

Comments (0)

Files changed (2)


   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


 # 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(),'')
-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/",
+            "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"
-["python", r"testdjangoproject/testdjango/",
+    print "hello from launch project production mode"
+    subprocess.check_call(["python", r"testdjangoproject/testdjango/",
+                     "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"