"""The installed wheel on the oldest Python it promises (3.9), with nothing else installed: the standard library and the package alone. python -I tests/smoke.py Prints one line per check and exits non-zero on the first that fails. """ import json import sys import tempfile import xml.etree.ElementTree as ET import wai_quantum as wq from wai_quantum import widgets BELL = "OPENQASM 3.0; qubit[2] q; bit[2] c; h q[0]; cx q[0], q[1]; c = measure q;" def main(): print("python", sys.version.split()[0], "wai_quantum", wq.__version__) demo = wq.Key.demo() job = wq.run(BELL, shots=1000, seed=7, key=demo) assert job.method == "stabilizer" and job.accuracy == "exact" and set(job.counts) <= {"00", "11"}, job.summary() assert wq.verify(json.loads(json.dumps(job))).valid print("run and verify:", job.summary()) forged = json.loads(json.dumps(job)) forged["result"]["counts"]["00"] += 1 assert not wq.verify(forged) print("a forged result does not verify") assert ET.fromstring(wq.draw(BELL, format="svg")).tag.endswith("svg") assert wq.equivalent("qubit[1] q; h q[0]; h q[0];", "qubit[1] q;")["verdict"] == "equivalent" b = wq.bloch("OPENQASM 3.0; qubit[1] q; h q[0];", key=demo) assert abs(b["qubits"][0]["x"] - 1) < 1e-12 print("draw, equivalent and bloch: ok") with tempfile.TemporaryDirectory() as d: import os os.environ["XDG_CONFIG_HOME"] = d k = wq.Key.user() assert wq.verify(wq.run(BELL, shots=10)).key == k.public_key print("the user's key: made and signed with") assert not widgets.HAVE_WIDGETS, "this check runs with the package alone" html = wq.Result(job)._repr_html_() + wq.Circuit(BELL)._repr_html_() + wq.Receipt(job)._repr_html_() assert "verified" in html and "