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

Function quantinuum_mock_server

python/tests/backends/conftest.py:31–62  ·  view source on GitHub ↗

Start the Quantinuum mock server and write a fake credentials file. Yields the path to the credentials file.

()

Source from the content-addressed store, hash-verified

29
30@pytest.fixture(scope="session")
31def quantinuum_mock_server():
32 """Start the Quantinuum mock server and write a fake credentials file.
33
34 Yields the path to the credentials file.
35 """
36 from network_utils import check_server_connection
37 try:
38 from utils.mock_qpu.quantinuum import startServer
39 except Exception:
40 pytest.skip("Mock qpu not available.", allow_module_level=False)
41
42 with open(QUANTINUUM_CREDS_FILE, 'w') as f:
43 f.write('key: {}\nrefresh: {}\ntime: 0'.format("nexus_key",
44 "nexus_refresh"))
45
46 cudaq.set_random_seed(13)
47
48 p = Process(target=startServer, args=(QUANTINUUM_MOCK_PORT,))
49 p.start()
50
51 if not check_server_connection(QUANTINUUM_MOCK_PORT):
52 p.terminate()
53 pytest.exit("Mock server did not start in time, skipping tests.",
54 returncode=1)
55
56 yield QUANTINUUM_CREDS_FILE
57
58 p.terminate()
59 try:
60 os.remove(QUANTINUUM_CREDS_FILE)
61 except FileNotFoundError:
62 pass
63
64
65# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected