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 gr...@apache.org on 2002/10/08 23:38:55 UTC

cvs commit: httpd-python/test/htdocs tests.py

grisha      2002/10/08 14:38:55

  Modified:    test     test.py testconf.py.in
               test/htdocs tests.py
  Added:       test     httpdconf.py
  Log:
  Major changes to the test script, which now is more or less organized
  but still needs multitudes of documentation and additional tests.
  Also added a httpdconf module as part of the test suite - it generates
  Httpd configs similar to the way HTMLgen works. Right now its very bare,
  but could eventually grow into something useful.
  
  Revision  Changes    Path
  1.12      +367 -371  httpd-python/test/test.py
  
  Index: test.py
  ===================================================================
  RCS file: /home/cvs/httpd-python/test/test.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- test.py	24 Sep 2002 16:01:28 -0000	1.11
  +++ test.py	8 Oct 2002 21:38:54 -0000	1.12
  @@ -1,46 +1,102 @@
  -
  + # ====================================================================
  + # The Apache Software License, Version 1.1
  + #
  + # Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + # reserved.
  + #
  + # Redistribution and use in source and binary forms, with or without
  + # modification, are permitted provided that the following conditions
  + # are met:
  + #
  + # 1. Redistributions of source code must retain the above copyright
  + #    notice, this list of conditions and the following disclaimer.
  + #
  + # 2. Redistributions in binary form must reproduce the above copyright
  + #    notice, this list of conditions and the following disclaimer in
  + #    the documentation and/or other materials provided with the
  + #    distribution.
  + #
  + # 3. The end-user documentation included with the redistribution,
  + #    if any, must include the following acknowledgment:
  + #       "This product includes software developed by the
  + #        Apache Software Foundation (http://www.apache.org/)."
  + #    Alternately, this acknowledgment may appear in the software itself,
  + #    if and wherever such third-party acknowledgments normally appear.
  + #
  + # 4. The names "Apache" and "Apache Software Foundation" must
  + #    not be used to endorse or promote products derived from this
  + #    software without prior written permission. For written
  + #    permission, please contact apache@apache.org.
  + #
  + # 5. Products derived from this software may not be called "Apache",
  + #    "mod_python", or "modpython", nor may these terms appear in their
  + #    name, without prior written permission of the Apache Software
  + #    Foundation.
  + #
  + # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + # SUCH DAMAGE.
  + # ====================================================================
  + #
  + # This software consists of voluntary contributions made by many
  + # individuals on behalf of the Apache Software Foundation.  For more
  + # information on the Apache Software Foundation, please see
  + # <http://www.apache.org/>.
  + #
  + # $Id$
  + #
  + 
   import testconf
  +from httpdconf import *
  +
  +import unittest
  +import commands
  +import urllib
  +import httplib
  +import os
  +import time
   
   HTTPD = testconf.HTTPD
   TESTHOME = testconf.TESTHOME
   PARAMS = {
       "server_root": TESTHOME,
  -    "config": TESTHOME + "/conf/test.conf",
  -    "config_tmpl": TESTHOME + "/conf/test.conf.tmpl",
  -    "document_root": TESTHOME + "/htdocs",
  -    "mod_python_so": TESTHOME + "/modules/mod_python.so",
  +    "config": os.path.join(TESTHOME, "conf", "test.conf"),
  +    "config_tmpl": os.path.join(TESTHOME, "conf", "test.conf.tmpl"),
  +    "document_root": os.path.join(TESTHOME, "htdocs"),
  +    "mod_python_so": os.path.join(TESTHOME, "modules", "mod_python.so"),
       "port": "", # this is set in fundUnusedPort()
       }
   
  -import unittest
  -import commands
  -import urllib
  -
  -
  -# need to incorporate the gdb into the testing process....
  -# httpd needs to be invoked under gdb [make optional], and
  -# the url fetching should be forked.
  -# what's the deal with gdb's being different?
  -
  -
  -def findUnusedPort():
  +def findUnusedPort(port=[54321]):
   
       # bind to port 0 which makes the OS find the next
       # unused port.
   
  -    import socket
  -    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  -    s.bind(("127.0.0.1", 0))
  -    port = s.getsockname()[1]
  -    s.close()
  +    try:
  +        import socket
  +        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  +        s.bind(("127.0.0.1", 0))
  +        port = s.getsockname()[1]
  +        s.close()
  +    except ImportError:
  +        # try without socket. this uses a python "static" trick,
  +        # a mutable default value for a keyword argument is defined
  +        # with the method, see section 7.5 of Python Ref. Manual.
  +        port += 1
   
       return port
   
  -class ModPythonTestCase(unittest.TestCase):
  -
  -    def __init__(self, methodName="runTest", configPart=""):
  -        unittest.TestCase.__init__(self, methodName)
  -        self.configPart = configPart
  +class HttpdCtrl:
  +    # a mixin providing ways to control httpd
   
       def makeConfig(self, append=""):
   
  @@ -60,264 +116,189 @@
           f.write("\n# --APPENDED-- \n\n"+append)
           f.close()
   
  -    def makeGdbFile(file):
  -        f = open(file, "w")
  -        f.write("run -f %s -X" % PARAMS("config"))
  -        f.close()
  -
  -    def startApache(self):
  +    def startHttpd(self):
   
           print "  Starting Apache...."
  -        print commands.getoutput("rm -f %s/logs/*log" % PARAMS["server_root"])
  -        cmd = '%s -f %s' % (HTTPD, PARAMS["config"])
  -        print "  ", cmd
  -        print commands.getoutput(cmd)
  -        self.apache_running = 1
  +        commands.getoutput("rm -f %s/logs/*log" % PARAMS["server_root"])
  +        cmd = '%s -k start -f %s' % (HTTPD, PARAMS["config"])
  +        print "    ", cmd
  +        commands.getoutput(cmd)
  +        self.httpd_running = 1
   
  -    def stopApache(self):
  -        print "  Stopping Apache..."
  -        pid = commands.getoutput("cat %s/logs/httpd.pid" % PARAMS["server_root"])
  -        commands.getoutput("kill "+pid)
  -        self.apache_running = 0
  +    def stopHttpd(self):
   
  -    def tearDown(self):
  -        if self.apache_running:
  -            self.stopApache()
  -
  -    def testLoadModule(self):
  -
  -        print "\n* Testing LoadModule"
  -
  -        self.makeConfig()
  -        self.startApache()
  -
  -        f = urllib.urlopen("http://127.0.0.1:%s/" % PARAMS["port"])
  -        server_hdr = f.info()["Server"]
  -        f.close()
  -        self.failUnless(server_hdr.find("Python") > -1,
  -                        "%s does not appear to load, Server header does not contain Python"
  -                        % PARAMS["mod_python_so"])
  +        print "  Stopping Apache..."
  +        cmd = '%s -k stop -f %s' % (HTTPD, PARAMS["config"]) 
  +        print "    ", cmd
  +        commands.getoutput(cmd)
  +        time.sleep(1)
  +        self.httpd_running = 0
   
  -    def test_apache_log_error(self):
  +class PerRequestTestCase(unittest.TestCase):
   
  -        print "\n* Testing apache.log_error()"
  +    appendConfig = "\nNameVirtualHost *\n\n"
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::apache_log_error\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  +    def __init__(self, methodName="runTest"):
  +        unittest.TestCase.__init__(self, methodName)
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +        # add to config
  +        try:
  +            confMeth = getattr(self, methodName+"_conf")
  +            self.__class__.appendConfig += confMeth() + "\n"
  +        except AttributeError:
  +            pass
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        print "    response: "+f.read()
  -        f.close()
  +    def vhost_get(self, vhost, path="/tests.py"):
  +        # allows to specify a custom host: header
   
  -        # see what's in the log now
  -        f = open("%s/logs/error_log" % PARAMS["server_root"])
  -        log = f.read()
  -        f.close()
  -        if log.find("This is a test message") == -1:
  -            self.fail("Could not find test message in error_log")
  +        conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
  +        conn.putrequest("GET", path, skip_host=1)
  +        conn.putheader("Host", "%s:%s" % (vhost, PARAMS["port"]))
  +        conn.endheaders()
  +        response = conn.getresponse()
  +        rsp = response.read()
  +        conn.close()
   
  -    def test_apache_table(self):
  +        return rsp
   
  -        print "\n* Testing apache.table()"
  +    def test_req_document_root_conf(self):
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::apache_table\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  +        c = VirtualHost("*",
  +                        ServerName("test_req_document_root"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_document_root"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
  -        self.makeConfig(cfg)
  -        self.startApache()
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "    response: "+rsp
  +    def test_req_document_root(self):
   
  -        if (rsp != "test ok"):
  -            self.fail("table test failed")
  +        print "\n  * Testing req.document_root()"
  +        rsp = self.vhost_get("test_req_document_root")
   
  -    def test_req_add_common_vars(self):
  +        if (rsp != PARAMS["document_root"]):
  +            self.fail("test failed")
   
  -        print "\n* Testing req.add_common_vars()"
  +    def test_req_add_handler_conf(self):
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_add_common_vars\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  +        c = VirtualHost("*",
  +                        ServerName("test_req_add_handler"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_add_handler"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +    def test_req_add_handler(self):
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "    response: "+rsp
  +        print "\n  * Testing req.add_handler()"
  +        rsp = self.vhost_get("test_req_add_handler")
   
           if (rsp != "test ok"):
               self.fail("test failed")
   
  -    def test_req_add_handler(self):
  -
  -        print "\n* Testing req.add_handler()"
  -
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_add_handler\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  +    def test_req_allow_methods_conf(self):
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  -
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "    response: "+rsp
  -
  -        if (rsp != "test ok"):
  -            self.fail("test failed")
  +        c = VirtualHost("*",
  +                        ServerName("test_req_allow_methods"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_allow_methods"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
       def test_req_allow_methods(self):
   
  -        print "\n* Testing req.allow_methods()"
  +        print "\n  * Testing req.allow_methods()"
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_allow_methods\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  -
  -        self.makeConfig(cfg)
  -        self.startApache()
  +        conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
  +        conn.putrequest("GET", "/tests.py", skip_host=1)
  +        conn.putheader("Host", "%s:%s" % ("test_req_allow_methods", PARAMS["port"]))
  +        conn.endheaders()
  +        response = conn.getresponse()
  +        server_hdr = response.getheader("Allow", "")
  +        conn.close()
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        server_hdr = f.info()["Allow"]
  -        f.close()
           self.failUnless(server_hdr.find("PYTHONIZE") > -1, "req.allow_methods() didn't work")
   
  -    def test_req_get_basic_auth_pw(self):
  -
  -        print "\n* Testing req.get_basic_auth_pw()"
  +    def test_req_get_basic_auth_pw_conf(self):
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  AuthType basic\n" + \
  -              "  require valid-user\n" + \
  -              "  AuthName restricted\n" + \
  -              "  PythonAuthenHandler tests::req_get_basic_auth_pw\n" + \
  -              "  PythonHandler tests::req_get_basic_auth_pw\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  +        c = VirtualHost("*",
  +                        ServerName("test_req_get_basic_auth_pw"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  AuthName("blah"),
  +                                  AuthType("basic"),
  +                                  require("valid-user"),
  +                                  PythonAuthenHandler("tests::req_get_basic_auth_pw"),
  +                                  PythonHandler("tests::req_get_basic_auth_pw"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +    def test_req_get_basic_auth_pw(self):
   
  -        url = "http://spam:eggs@127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +        print "\n  * Testing req.get_basic_auth_pw()"
           
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "    response: "+rsp
  +        conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
  +        conn.putrequest("GET", "/tests.py", skip_host=1)
  +        conn.putheader("Host", "%s:%s" % ("test_req_get_basic_auth_pw", PARAMS["port"]))
  +        import base64
  +        auth = base64.encodestring("spam:eggs").strip()
  +        conn.putheader("Authorization", "Basic %s" % auth)
  +        conn.endheaders()
  +        response = conn.getresponse()
  +        rsp = response.read()
  +        conn.close()
   
           if (rsp != "test ok"):
               self.fail("test failed")
   
  -    def test_req_document_root(self):
  -
  -        print "\n* Testing req.document_root()"
  -
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_document_root\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  -
  -        self.makeConfig(cfg)
  -        self.startApache()
  -
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "    response: "+rsp
  +    def test_req_internal_redirect_conf(self):
   
  -        if (rsp != PARAMS["document_root"]):
  -            self.fail("test failed")
  +        c = VirtualHost("*",
  +                        ServerName("test_req_internal_redirect"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_internal_redirect | .py"),
  +                                  PythonHandler("tests::req_internal_redirect_int | .int"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
       def test_req_internal_redirect(self):
   
  -        print "\n* Testing req.internal_redirect()"
  -
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_internal_redirect | .py\n" + \
  -              "  PythonHandler tests::req_internal_redirect_int | .int\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  -
  -        self.makeConfig(cfg)
  -        self.startApache()
  +        print "\n  * Testing req.internal_redirect()"
  +        rsp = self.vhost_get("test_req_internal_redirect")
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "response: ", rsp
  -        
           if rsp != "test ok":
               self.fail("internal_redirect")
   
  -    def test_req_read(self):
  -
  -        print "\n* Testing req.read()"
  +    def test_req_read_conf(self):
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_read\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n" + \
  -              "Timeout 10\n"
  +        c = str(Timeout("5")) + \
  +            str(VirtualHost("*",
  +                        ServerName("test_req_read"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_read"),
  +                                  PythonDebug("On"))))
  +        return c
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +    def test_req_read(self):
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +        print "\n  * Testing req.read()"
   
  -        import httplib
           params = '1234567890'*10000
           print "    writing %d bytes..." % len(params)
           conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
  -        conn.putrequest("POST", "/tests.py")
  -        conn.putheader("Host", "127.0.0.1:%s" % PARAMS["port"])
  +        conn.putrequest("POST", "/tests.py", skip_host=1)
  +        conn.putheader("Host", "test_req_read:%s" % PARAMS["port"])
           conn.putheader("Content-Length", len(params))
           conn.endheaders()
           conn.send(params)
  @@ -329,10 +310,10 @@
           if (rsp != params):
               self.fail("test failed")
   
  -        print "    read/write ok, now lets try causing a timeout (should be 10 secs)"
  +        print "    read/write ok, now lets try causing a timeout (should be 5 secs)"
           conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
  -        conn.putrequest("POST", "/tests.py")
  -        conn.putheader("Host", "127.0.0.1:%s" % PARAMS["port"])
  +        conn.putrequest("POST", "/tests.py", skip_host=1)
  +        conn.putheader("Host", "test_req_read:%s" % PARAMS["port"])
           conn.putheader("Content-Length", 10)
           conn.endheaders()
           conn.send("123456789")
  @@ -343,29 +324,27 @@
           if rsp.find("IOError") < 0:
               self.fail("timeout test failed")
   
  -    def test_req_readline(self):
   
  -        print "\n* Testing req.readline()"
  +    def test_req_readline_conf(self):
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_readline\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n" + \
  -              "Timeout 10\n"
  +        c = VirtualHost("*",
  +                        ServerName("test_req_readline"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_readline"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +    def test_req_readline(self):
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +        print "\n  * Testing req.readline()"
   
  -        import httplib
           params = ('1234567890'*3000+'\n')*4
           print "    writing %d bytes..." % len(params)
           conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
  -        conn.putrequest("POST", "/tests.py")
  -        conn.putheader("Host", "127.0.0.1:%s" % PARAMS["port"])
  +        conn.putrequest("POST", "/tests.py", skip_host=1)
  +        conn.putheader("Host", "test_req_readline:%s" % PARAMS["port"])
           conn.putheader("Content-Length", len(params))
           conn.endheaders()
           conn.send(params)
  @@ -377,29 +356,26 @@
           if (rsp != params):
               self.fail("test failed")
   
  -    def test_req_readlines(self):
  +    def test_req_readlines_conf(self):
   
  -        print "\n* Testing req.readlines()"
  +        c = VirtualHost("*",
  +                        ServerName("test_req_readlines"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_readlines"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_readlines\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n" + \
  -              "Timeout 10\n"
  -
  -        self.makeConfig(cfg)
  -        self.startApache()
  +    def test_req_readlines(self):
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +        print "\n  * Testing req.readlines()"
   
  -        import httplib
           params = ('1234567890'*3000+'\n')*4
           print "    writing %d bytes..." % len(params)
           conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
  -        conn.putrequest("POST", "/tests.py")
  -        conn.putheader("Host", "127.0.0.1:%s" % PARAMS["port"])
  +        conn.putrequest("POST", "/tests.py", skip_host=1)
  +        conn.putheader("Host", "test_req_readlines:%s" % PARAMS["port"])
           conn.putheader("Content-Length", len(params))
           conn.endheaders()
           conn.send(params)
  @@ -411,55 +387,49 @@
           if (rsp != params):
               self.fail("test failed")
   
  -    def test_req_register_cleanup(self):
  +    def test_req_register_cleanup_conf(self):
   
  -        print "\n* Testing req.register_cleanup()"
  +        c = VirtualHost("*",
  +                        ServerName("test_req_register_cleanup"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::req_register_cleanup"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::req_register_cleanup\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  +    def test_req_register_cleanup(self):
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +        print "\n  * Testing req.register_cleanup()"
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -        
  -        f = urllib.urlopen(url)
  -        print "    response: "+f.read()
  -        f.close()
  -        import time
  -        time.sleep(1)
  +        rsp = self.vhost_get("test_req_register_cleanup")
           
           # see what's in the log now
  +        time.sleep(1)
           f = open("%s/logs/error_log" % PARAMS["server_root"])
           log = f.read()
           f.close()
           if log.find("test ok") == -1:
               self.fail("Could not find test message in error_log")
   
  -    def test_util_fieldstorage(self):
  -
  -        print "\n* Testing util_fieldstorage()"
  -
  -        cfg = "<Directory %s/htdocs>\n" % PARAMS["server_root"]+ \
  -              "  SetHandler python-program\n" + \
  -              "  PythonHandler tests::util_fieldstorage\n" + \
  -              "  PythonDebug On\n" + \
  -              "</Directory>\n"
  +    def test_util_fieldstorage_conf(self):
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +        c = VirtualHost("*",
  +                        ServerName("test_util_fieldstorage"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests::util_fieldstorage"),
  +                                  PythonDebug("On")))
  +        return str(c)
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +    def test_util_fieldstorage(self):
   
  -        import httplib
  +        print "\n  * Testing util_fieldstorage()"
   
           params = urllib.urlencode([('spam',1),('spam',2),('eggs',3),('bacon',4)])
  -        headers = {"Content-type": "application/x-www-form-urlencoded",
  +        headers = {"Host": "test_util_fieldstorage",
  +                   "Content-type": "application/x-www-form-urlencoded",
                      "Accept": "text/plain"}
           conn = httplib.HTTPConnection("127.0.0.1:%s" % PARAMS["port"])
           conn.request("POST", "/tests.py", params, headers)
  @@ -467,122 +437,148 @@
           rsp = response.read()
           conn.close()
   
  -        print "    response: ", rsp
           if (rsp != "[Field('spam', '1'), Field('spam', '2'), Field('eggs', '3'), Field('bacon', '4')]"):
               self.fail("test failed")
   
  -    def test_postreadrequest(self):
  -
  -        print "\n* Testing PostReadRequestHandler"
  +    def test_postreadrequest_conf(self):
   
  -        cfg = "  SetHandler python-program\n" + \
  -              "  PythonPath ['%s']+sys.path\n" % PARAMS["document_root"] + \
  -              "  PythonPostReadRequestHandler tests::postreadrequest\n" + \
  -              "  PythonDebug On\n"
  +        c = VirtualHost("*",
  +                        ServerName("test_postreadrequest"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        SetHandler("python-program"),
  +                        PythonPath("['%s']+sys.path" % PARAMS["document_root"]),
  +                        PythonHandler("tests::postreadrequest"),
  +                        PythonDebug("On"))
  +        return str(c)
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  -
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +    def test_postreadrequest(self):
   
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "    response: "
  +        print "\n  * Testing PostReadRequestHandler"
  +        rsp = self.vhost_get("test_postreadrequest")
   
           if (rsp != "test ok"):
               self.fail("test failed")
   
  -    def test_outputfilter(self):
  +    def test_outputfilter_conf(self):
   
  -        print "\n* Testing PythonOutputFilter"
  +        c = VirtualHost("*",
  +                        ServerName("test_outputfilter"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        SetHandler("python-program"),
  +                        PythonPath("['%s']+sys.path" % PARAMS["document_root"]),
  +                        PythonHandler("tests::simplehandler"),
  +                        PythonOutputFilter("tests::outputfilter MP_TEST_FILTER"),
  +                        PythonDebug("On"),
  +                        AddOutputFilter("MP_TEST_FILTER .py"))
  +        return str(c)
   
  -        cfg = "  SetHandler python-program\n" + \
  -              "  PythonPath ['%s']+sys.path\n" % PARAMS["document_root"] + \
  -              "  PythonHandler tests::simplehandler\n" + \
  -              "  PythonOutputFilter tests::outputfilter MP_TEST_FILTER\n" + \
  -              "  PythonDebug On\n" + \
  -              "  AddOutputFilter MP_TEST_FILTER .py\n"
  -
  -        self.makeConfig(cfg)
  -        self.startApache()
  +    def test_outputfilter(self):
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  -
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  -        f.close()
  -        print "    response: ", rsp
  +        print "\n  * Testing PythonOutputFilter"
  +        rsp = self.vhost_get("test_outputfilter")
   
           if (rsp != "TEST OK"):
               self.fail("test failed")
   
  -    def test_connectionhandler(self):
  -
  -        print "\n* Testing PythonConnectionHandler"
  +    def test_connectionhandler_conf(self):
   
  -        cfg = "  SetHandler python-program\n" + \
  -              "  PythonPath ['%s']+sys.path\n" % PARAMS["document_root"] + \
  -              "  PythonConnectionHandler tests::connectionhandler\n"
  +        self.conport = findUnusedPort()
  +        c = str(Listen("%d" % self.conport)) + \
  +            str(VirtualHost("127.0.0.1:%d" % self.conport,
  +                            SetHandler("python-program"),
  +                            PythonPath("['%s']+sys.path" % PARAMS["document_root"]),
  +                            PythonConnectionHandler("tests::connectionhandler")))
  +        return c
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +    def test_connectionhandler(self):
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +        print "\n  * Testing PythonConnectionHandler"
   
  +        url = "http://127.0.0.1:%s/tests.py" % self.conport
           f = urllib.urlopen(url)
           rsp = f.read()
           f.close()
  -        print "    response: ", rsp
   
           if (rsp != "test ok"):
               self.fail("test failed")
   
  +    def test_internal_conf(self):
  +
  +        c = VirtualHost("*",
  +                        ServerName("test_internal"),
  +                        DocumentRoot(PARAMS["document_root"]),
  +                        Directory(PARAMS["document_root"],
  +                                  SetHandler("python-program"),
  +                                  PythonHandler("tests"),
  +                                  PythonOption("testing 123"),
  +                                  PythonDebug("On")))
  +        return str(c)
  +
       def test_internal(self):
   
  -        print "\n* Testing internally"
  +        print "\n  * Testing internally"
  +        rsp = self.vhost_get("test_internal")
   
  -        cfg = "  SetHandler python-program\n" + \
  -              "  PythonPath ['%s']+sys.path\n" % PARAMS["document_root"] + \
  -              "  PythonHandler tests\n" + \
  -              "  PythonOption testing 123\n" + \
  -              "  PythonDebug On\n"
  +        if (rsp[-7:] != "test ok"):
  +            self.fail("Some tests failed, see error_log")
   
  -        self.makeConfig(cfg)
  -        self.startApache()
  +class PerInstanceTestCase(unittest.TestCase, HttpdCtrl):
  +    # this is a test case which requires a complete
  +    # restart of httpd (e.g. we're using a fancy config)
   
  -        url = "http://127.0.0.1:%s/tests.py" % PARAMS["port"]
  -        print "    url: "+url
  +    def tearDown(self):
  +        if self.httpd_running:
  +            self.stopHttpd()
   
  -        f = urllib.urlopen(url)
  -        rsp = f.read()
  +    def testLoadModule(self):
  +
  +        print "\n* Testing LoadModule"
  +
  +        self.makeConfig()
  +        self.startHttpd()
  +
  +        f = urllib.urlopen("http://127.0.0.1:%s/" % PARAMS["port"])
  +        server_hdr = f.info()["Server"]
           f.close()
  -        print "    response: ", rsp
  +        self.failUnless(server_hdr.find("Python") > -1,
  +                        "%s does not appear to load, Server header does not contain Python"
  +                        % PARAMS["mod_python_so"])
  +
  +
  +    def testPerRequestTests(self):
  +
  +        print "\n* Running the per-request test suite..."
  +
  +        perRequestSuite = unittest.TestSuite()
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_document_root"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_add_handler"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_allow_methods"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_get_basic_auth_pw"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_internal_redirect"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_read"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_readline"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_readlines"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_req_register_cleanup"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_util_fieldstorage"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_postreadrequest"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_outputfilter"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_connectionhandler"))
  +        perRequestSuite.addTest(PerRequestTestCase("test_internal"))
  +
  +        self.makeConfig(PerRequestTestCase.appendConfig)
  +        self.startHttpd()
  +
  +        tr = unittest.TextTestRunner()
  +        result = tr.run(perRequestSuite)
  +
  +        self.failUnless(result.wasSuccessful())
   
  -        if (rsp[-7:] != "test ok"):
  -            self.fail("Some tests failed, see error_log")
   
   def suite():
   
       mpTestSuite = unittest.TestSuite()
  -    mpTestSuite.addTest(ModPythonTestCase("testLoadModule"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_internal"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_add_handler"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_allow_methods"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_document_root"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_get_basic_auth_pw"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_internal_redirect"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_read"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_readline"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_readlines"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_req_register_cleanup"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_util_fieldstorage"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_postreadrequest"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_outputfilter"))
  -    mpTestSuite.addTest(ModPythonTestCase("test_connectionhandler"))
  +    mpTestSuite.addTest(PerInstanceTestCase("testLoadModule"))
  +    mpTestSuite.addTest(PerInstanceTestCase("testPerRequestTests"))
       return mpTestSuite
   
   tr = unittest.TextTestRunner()
  
  
  
  1.2       +2 -0      httpd-python/test/testconf.py.in
  
  Index: testconf.py.in
  ===================================================================
  RCS file: /home/cvs/httpd-python/test/testconf.py.in,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- testconf.py.in	18 Aug 2002 18:43:36 -0000	1.1
  +++ testconf.py.in	8 Oct 2002 21:38:54 -0000	1.2
  @@ -1,4 +1,6 @@
   
  +# This file is autogenerated by ./configure
  +
   HTTPD="@HTTPD@"
   TESTHOME="@TEST_SERVER_ROOT@"
   
  
  
  
  1.1                  httpd-python/test/httpdconf.py
  
  Index: httpdconf.py
  ===================================================================
   # ====================================================================
   # The Apache Software License, Version 1.1
   #
   # Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   # reserved.
   #
   # Redistribution and use in source and binary forms, with or without
   # modification, are permitted provided that the following conditions
   # are met:
   #
   # 1. Redistributions of source code must retain the above copyright
   #    notice, this list of conditions and the following disclaimer.
   #
   # 2. Redistributions in binary form must reproduce the above copyright
   #    notice, this list of conditions and the following disclaimer in
   #    the documentation and/or other materials provided with the
   #    distribution.
   #
   # 3. The end-user documentation included with the redistribution,
   #    if any, must include the following acknowledgment:
   #       "This product includes software developed by the
   #        Apache Software Foundation (http://www.apache.org/)."
   #    Alternately, this acknowledgment may appear in the software itself,
   #    if and wherever such third-party acknowledgments normally appear.
   #
   # 4. The names "Apache" and "Apache Software Foundation" must
   #    not be used to endorse or promote products derived from this
   #    software without prior written permission. For written
   #    permission, please contact apache@apache.org.
   #
   # 5. Products derived from this software may not be called "Apache",
   #    "mod_python", or "modpython", nor may these terms appear in their
   #    name, without prior written permission of the Apache Software
   #    Foundation.
   #
   # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   # SUCH DAMAGE.
   # ====================================================================
   #
   # This software consists of voluntary contributions made by many
   # individuals on behalf of the Apache Software Foundation.  For more
   # information on the Apache Software Foundation, please see
   # <http://www.apache.org/>.
   #
   # $Id: httpdconf.py,v 1.1 2002/10/08 21:38:54 grisha Exp $
   #
   # Config maker, a la HTMLGen. This could grow into something useful.
   #
  
  class Directive:
  
      def __init__(self, name, val):
          self.name = name
          self.val = val
          self.indent = 0
  
      def __str__(self):
  
          i = " " * self.indent
          return i + '%s %s\n' % (self.name, self.val)
  
  class ContainerTag:
  
      def __init__(self, tag, attr, args):
          self.tag = tag
          self.attr = attr
          self.args = args
          self.indent = 0
  
      def __str__(self):
  
          i = " " * self.indent
  
          s = i + "<%s %s>\n" % (self.tag, self.attr)
          for arg in self.args:
              arg.indent = self.indent + 2
              s += i + "%s" % str(arg)
          s += i + "</%s>\n" % self.tag
  
          return s
  
  class AddOutputFilter(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class AuthType(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class AuthName(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class Directory(ContainerTag):
      def __init__(self, dir, *args):
          ContainerTag.__init__(self, self.__class__.__name__, dir, args)
  
  class DocumentRoot(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class Listen(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class PythonAuthenHandler(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class PythonConnectionHandler(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class PythonHandler(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class PythonDebug(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class PythonPath(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class PythonOutputFilter(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class PythonOption(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class require(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class SetHandler(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class ServerName(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class Timeout(Directive):
      def __init__(self, val):
          Directive.__init__(self, self.__class__.__name__, val)
  
  class VirtualHost(ContainerTag):
      def __init__(self, addr, *args):
          ContainerTag.__init__(self, self.__class__.__name__, addr, args)
  
  
  
  
  
  1.10      +63 -7     httpd-python/test/htdocs/tests.py
  
  Index: tests.py
  ===================================================================
  RCS file: /home/cvs/httpd-python/test/htdocs/tests.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- tests.py	24 Sep 2002 16:01:28 -0000	1.9
  +++ tests.py	8 Oct 2002 21:38:55 -0000	1.10
  @@ -1,3 +1,59 @@
  + # ====================================================================
  + # The Apache Software License, Version 1.1
  + #
  + # Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + # reserved.
  + #
  + # Redistribution and use in source and binary forms, with or without
  + # modification, are permitted provided that the following conditions
  + # are met:
  + #
  + # 1. Redistributions of source code must retain the above copyright
  + #    notice, this list of conditions and the following disclaimer.
  + #
  + # 2. Redistributions in binary form must reproduce the above copyright
  + #    notice, this list of conditions and the following disclaimer in
  + #    the documentation and/or other materials provided with the
  + #    distribution.
  + #
  + # 3. The end-user documentation included with the redistribution,
  + #    if any, must include the following acknowledgment:
  + #       "This product includes software developed by the
  + #        Apache Software Foundation (http://www.apache.org/)."
  + #    Alternately, this acknowledgment may appear in the software itself,
  + #    if and wherever such third-party acknowledgments normally appear.
  + #
  + # 4. The names "Apache" and "Apache Software Foundation" must
  + #    not be used to endorse or promote products derived from this
  + #    software without prior written permission. For written
  + #    permission, please contact apache@apache.org.
  + #
  + # 5. Products derived from this software may not be called "Apache",
  + #    "mod_python", or "modpython", nor may these terms appear in their
  + #    name, without prior written permission of the Apache Software
  + #    Foundation.
  + #
  + # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + # SUCH DAMAGE.
  + # ====================================================================
  + #
  + # This software consists of voluntary contributions made by many
  + # individuals on behalf of the Apache Software Foundation.  For more
  + # information on the Apache Software Foundation, please see
  + # <http://www.apache.org/>.
  + #
  + # $Id$
  + #
   
   # mod_python tests
   
  @@ -114,8 +170,8 @@
               self.fail("req.proto_num doesn't match req.protocol")
   
           log("    req.hostname: %s" % `req.hostname`)
  -        if req.hostname != "127.0.0.1":
  -            self.fail("req.hostname isn't '127.0.0.1'")
  +        if req.hostname != "test_internal":
  +            self.fail("req.hostname isn't 'test_internal'")
   
           log("    req.request_time: %s" % `req.request_time`)
           if (time.time() - req.request_time) > 2:
  @@ -167,8 +223,8 @@
               self.fail("req.mtime should be 0")
           
           log("    req.chunked: %s" % `req.chunked`)
  -        if req.chunked != 0:
  -            self.fail("req.chunked should be 0")
  +        if req.chunked != 1:
  +            self.fail("req.chunked should be 1")
               
           log("    req.range: %s" % `req.range`)
           if req.range:
  @@ -201,9 +257,9 @@
           if req.expecting_100 != 0:
               self.fail("req.expecting_100 should be 0")
   
  -        log("    req.headers_int: %s" % `req.headers_in`)
  -        if req.headers_in["User-agent"][:13].lower() != "python-urllib":
  -            self.fail("The 'user-agnet' header should begin with 'Python-urllib'")
  +        log("    req.headers_in: %s" % `req.headers_in`) 
  +        if req.headers_in["Host"][:13].lower() != "test_internal":
  +            self.fail("The 'Host' header should begin with 'test_internal'")
               
           log("    req.headers_out: %s" % `req.headers_out`)
           if ((not req.headers_out.has_key("content-length")) or