test.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:httpimport 作者: operatorequals 项目源码 文件源码
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!
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号