def test_simple_HTTP(self) :
# ============== Setting up an HTTP server at 'http://localhost:8001/' in current directory
try :
PORT = int(sys.argv[1])
except :
PORT = randint(1025, 65535)
try :
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
except :
Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
print ("Serving at port %d" % PORT)
http_thread = Thread( target = httpd.serve_forever, )
http_thread.daemon = True
# ============== Starting the HTTP server
http_thread.start()
# ============== Wait until HTTP server is ready
sleep(1)
with remote_repo(['test_package'], base_url = 'http://localhost:%d/' % PORT) :
from test_package import module1
self.assertTrue(module1.dummy_str) # If this point is reached then the module1 is imported succesfully!
评论列表
文章目录