Commits

cleemesser committed 49744a7

mostly work experimenting with unittest

  • Participants
  • Parent commits 79ba12b

Comments (0)

Files changed (2)

django_wsgiserver/management/commands/runwsgiserver.py

   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
+
 
 Examples:
   Run a "standard" CherryPy wsgi server--good for local development

tests/test_project.py

 # 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",
                      "runwsgiserver",
+                     "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):
         time.sleep(1)
         r = self.session.get(r'http://localhost:8000/')
 
 
         
-    def tearDown(self):
-        stop_project()
+
     
     
 
 
 def main():
     try:    
-        launch_project()
+        launch_project_developer_mode()
         print "started project"
         time.sleep(1.0)
         do_tests()