Switch to threaded python server for tests.
This commit is contained in:
parent
7bd8887860
commit
aa23916326
11
test/test.py
11
test/test.py
@ -15,9 +15,10 @@
|
||||
import json, platform, os, shutil, sys, subprocess, tempfile, threading
|
||||
import time, urllib, urllib2, hashlib, re, base64, uuid, socket, errno
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
import SocketServer
|
||||
from SocketServer import ThreadingMixIn
|
||||
from optparse import OptionParser
|
||||
from urlparse import urlparse, parse_qs
|
||||
from threading import Lock
|
||||
|
||||
USAGE_EXAMPLE = "%prog"
|
||||
|
||||
@ -35,6 +36,8 @@ BROWSER_TIMEOUT = 60
|
||||
|
||||
SERVER_HOST = "localhost"
|
||||
|
||||
lock = Lock()
|
||||
|
||||
class TestOptions(OptionParser):
|
||||
def __init__(self, **kwargs):
|
||||
OptionParser.__init__(self, **kwargs)
|
||||
@ -134,8 +137,8 @@ class Result:
|
||||
self.failure = failure
|
||||
self.page = page
|
||||
|
||||
class TestServer(SocketServer.TCPServer):
|
||||
allow_reuse_address = True
|
||||
class TestServer(ThreadingMixIn, HTTPServer):
|
||||
pass
|
||||
|
||||
class TestHandlerBase(BaseHTTPRequestHandler):
|
||||
# Disable annoying noise by default
|
||||
@ -243,6 +246,7 @@ class UnitTestHandler(TestHandlerBase):
|
||||
return
|
||||
|
||||
def do_POST(self):
|
||||
with lock:
|
||||
url = urlparse(self.path)
|
||||
numBytes = int(self.headers['Content-Length'])
|
||||
content = self.rfile.read(numBytes)
|
||||
@ -310,6 +314,7 @@ class PDFTestHandler(TestHandlerBase):
|
||||
|
||||
|
||||
def do_POST(self):
|
||||
with lock:
|
||||
numBytes = int(self.headers['Content-Length'])
|
||||
|
||||
self.send_response(200)
|
||||
|
Loading…
x
Reference in New Issue
Block a user