MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / startUpMockServer

Function startUpMockServer

python/tests/backends/test_IQM.py:40–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39@pytest.fixture(scope="session", autouse=True)
40def startUpMockServer():
41 # Write a fake access tokens file
42 with tempfile.NamedTemporaryFile(delete=False) as tmp_tokens_file:
43 write_a_mock_tokens_file(tmp_tokens_file.name)
44
45 # Launch the Mock Server
46 p = Process(target=startServer, args=(port,))
47 p.start()
48
49 if not check_server_connection(port):
50 p.terminate()
51 pytest.exit("Mock server did not start in time, skipping tests.",
52 returncode=1)
53
54 cudaq.set_random_seed(13)
55 # Set the targeted QPU
56 os.environ["IQM_TOKENS_FILE"] = tmp_tokens_file.name
57 cudaq.set_target("iqm", url="http://localhost:{}".format(port))
58
59 yield "Running the tests."
60
61 # Kill the server, remove the tokens file
62 p.terminate()
63 os.remove(tmp_tokens_file.name)
64
65 cudaq.reset_target()
66
67
68def test_iqm_ghz():

Callers

nothing calls this directly

Calls 5

write_a_mock_tokens_fileFunction · 0.90
check_server_connectionFunction · 0.90
exitMethod · 0.80
formatMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected