Commits

Brodie Rao committed 1bf46b3

tests: add support for running the tests under BaseHTTPServer

Comments (0)

Files changed (1)

test/test_akismet.py

 
 if __name__ == '__main__':
     if not 'SCRIPT_NAME' in os.environ:
-        print 'This script must be run as a CGI'
+        import CGIHTTPServer
+        import BaseHTTPServer
+
+        class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
+            cgi_directories = ['/', '/test']
+
+        server = BaseHTTPServer.HTTPServer(('localhost', 9000), Handler)
+        server.serve_forever()
     else:
         main()
 
 
 It tests ``verify_key`` and ``comment_check`` in 80 lines of code
 
-"""
+"""