25
25
t = LocalTransport('.')
26
26
transport_test(self, t)
28
class HttpServer(object):
29
"""This just encapsulates spawning and stopping
33
"""This just spawns a separate process to serve files from
34
this directory. Call the .stop() function to kill the
37
from BaseHTTPServer import HTTPServer
38
from SimpleHTTPServer import SimpleHTTPRequestHandler
40
if hasattr(os, 'fork'):
44
else: # How do we handle windows, which doesn't have fork?
45
raise NotImplementedError('At present HttpServer cannot fork on Windows')
47
# We might be able to do something like os.spawn() for the
48
# python executable, and give it a simple script to run.
49
# but then how do we kill it?
52
self.s = HTTPServer(('', 9999), SimpleHTTPRequestHandler)
53
# TODO: Is there something nicer than killing the server when done?
54
self.s.serve_forever()
55
except KeyboardInterrupt:
63
if hasattr(os, 'kill'):
65
os.kill(self.pid, signal.SIGINT)
66
os.waitpid(self.pid, 0)
69
raise NotImplementedError('At present HttpServer cannot stop on Windows')
71
class HttpTransportTest(InTempDir):
73
from bzrlib.transport import transport_test_ro
74
from bzrlib.http_transport import HttpTransport
78
t = HttpTransport('http://localhost:9999/')
79
transport_test_ro(self, t)