You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by nl...@apache.org on 2005/08/06 11:10:44 UTC

svn commit: r230541 - in /httpd/mod_python/trunk/test: htdocs/tests.py test.py

Author: nlehuen
Date: Sat Aug  6 02:10:03 2005
New Revision: 230541

URL: http://svn.apache.org/viewcvs?rev=230541&view=rev
Log:
Added tests for apache.register_cleanup.

Modified:
    httpd/mod_python/trunk/test/htdocs/tests.py
    httpd/mod_python/trunk/test/test.py

Modified: httpd/mod_python/trunk/test/htdocs/tests.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/htdocs/tests.py?rev=230541&r1=230540&r2=230541&view=diff
==============================================================================
--- httpd/mod_python/trunk/test/htdocs/tests.py (original)
+++ httpd/mod_python/trunk/test/htdocs/tests.py Sat Aug  6 02:10:03 2005
@@ -693,6 +693,14 @@
 
     return apache.OK
 
+def apache_register_cleanup(req):
+
+    req.cleanup_data = "test 2 ok"
+    apache.register_cleanup(cleanup, req)
+    req.write("registered server cleanup that will write to log")
+
+    return apache.OK
+
 def util_fieldstorage(req):
 
     from mod_python import util

Modified: httpd/mod_python/trunk/test/test.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/test.py?rev=230541&r1=230540&r2=230541&view=diff
==============================================================================
--- httpd/mod_python/trunk/test/test.py (original)
+++ httpd/mod_python/trunk/test/test.py Sat Aug  6 02:10:03 2005
@@ -1425,11 +1425,41 @@
         if log.find("test ok") == -1:
             self.fail("Could not find test message in error_log")
 
+    def test_apache_register_cleanup(self):
+
+        print "\n* Testing apache.register_cleanup()..."
+
+        c = Directory(DOCUMENT_ROOT,
+                      SetHandler("mod_python"),
+                      PythonHandler("tests::apache_register_cleanup"),
+                      PythonDebug("On"))
+
+        self.makeConfig(str(c))
+
+        self.startHttpd()
+
+        f = urllib.urlopen("http://127.0.0.1:%s/tests.py" % PORT)
+        f.read()
+        f.close()
+
+        time.sleep(2)
+
+        self.stopHttpd()
+
+        # see what's in the log now
+        time.sleep(2)
+        f = open(os.path.join(SERVER_ROOT, "logs/error_log"))
+        log = f.read()
+        f.close()
+        if log.find("test 2 ok") == -1:
+            self.fail("Could not find test message in error_log")
+
 def suite():
 
     mpTestSuite = unittest.TestSuite()
     mpTestSuite.addTest(PerInstanceTestCase("testLoadModule"))
     mpTestSuite.addTest(PerInstanceTestCase("test_srv_register_cleanup"))
+    mpTestSuite.addTest(PerInstanceTestCase("test_apache_register_cleanup"))
     # XXX comment out until ab is fixed, or we have another way
 ##     mpTestSuite.addTest(PerInstanceTestCase("test_global_lock"))
     mpTestSuite.addTest(PerInstanceTestCase("testPerRequestTests"))