MCPcopy Create free account
hub / github.com/Kaggle/docker-python / create_test_server

Function create_test_server

tests/test_kaggle_module_resolver.py:18–37  ·  view source on GitHub ↗
(handler_class)

Source from the content-addressed store, hash-verified

16
17@contextmanager
18def create_test_server(handler_class):
19 hostname = 'localhost'
20 port = 8080
21 addr = f"http://{hostname}:{port}"
22
23 # Simulates we are inside a Kaggle environment.
24 env = EnvironmentVarGuard()
25 env.set('KAGGLE_KERNEL_RUN_TYPE', 'Interactive')
26 env.set('KAGGLE_USER_SECRETS_TOKEN', 'foo jwt token')
27 env.set('KAGGLE_DATA_PROXY_TOKEN', 'foo proxy token')
28 env.set('KAGGLE_DATA_PROXY_URL', addr)
29
30 with env:
31 with HTTPServer((hostname, port), handler_class) as test_server:
32 threading.Thread(target=test_server.serve_forever).start()
33
34 try:
35 yield addr
36 finally:
37 test_server.shutdown()
38
39class HubHTTPHandler(BaseHTTPRequestHandler):
40 def do_GET(self):

Calls

no outgoing calls

Tested by

no test coverage detected