Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cbjuan committed Jul 30, 2024
1 parent be8666d commit 011aef3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
4 changes: 1 addition & 3 deletions tests/ai/test_clifford_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def test_clifford_wrong_url(monkeypatch, random_circuit_transpiled, backend):
ai_optimized_circuit = ai_optimize_lf.run(random_circuit_transpiled)
pytest.fail("Error expected")
except Exception as e:
assert "Expecting value: line 1 column 1 (char 0)" in str(
e
)
assert "Expecting value: line 1 column 1 (char 0)" in str(e)
assert type(e).__name__ == "JSONDecodeError"


Expand Down
4 changes: 1 addition & 3 deletions tests/ai/test_linear_function_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ def test_linear_function_wrong_url(monkeypatch, random_circuit_transpiled, backe
ai_optimized_circuit = ai_optimize_lf.run(random_circuit_transpiled)
pytest.fail("Error expected")
except Exception as e:
assert "Expecting value: line 1 column 1 (char 0)" in str(
e
)
assert "Expecting value: line 1 column 1 (char 0)" in str(e)
assert type(e).__name__ == "JSONDecodeError"


Expand Down
8 changes: 2 additions & 6 deletions tests/ai/test_permutation_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,14 @@ def test_permutation_wrong_url(monkeypatch, random_circuit_transpiled, backend):
ai_optimize_lf = PassManager(
[
CollectPermutations(min_block_size=2, max_block_size=27),
AIPermutationSynthesis(
backend_name=backend, base_url="https://ibm.com/"
),
AIPermutationSynthesis(backend_name=backend, base_url="https://ibm.com/"),
]
)
try:
ai_optimized_circuit = ai_optimize_lf.run(random_circuit_transpiled)
pytest.fail("Error expected")
except Exception as e:
assert "Expecting value: line 1 column 1 (char 0)" in str(
e
)
assert "Expecting value: line 1 column 1 (char 0)" in str(e)
assert type(e).__name__ == "JSONDecodeError"


Expand Down
19 changes: 7 additions & 12 deletions tests/ai/test_routing_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ def test_routing_wrong_backend(random_circuit_transpiled):
ai_optimized_circuit = ai_optimize_lf.run(random_circuit_transpiled)
pytest.fail("Error expected")
except Exception as e:
assert "User doesn't have access to the specified backend: wrong_backend" in str(
e
assert (
"User doesn't have access to the specified backend: wrong_backend" in str(e)
)


@pytest.mark.skip(
reason="Unreliable. It passes most of the times with the timeout of 1 second for the current circuits used"
)
Expand All @@ -89,9 +90,7 @@ def test_routing_wrong_token(qv_circ, backend):
ai_optimized_circuit = ai_optimize_lf.run(qv_circ)
pytest.fail("Error expected")
except Exception as e:
assert "Invalid authentication credentials" in str(
e
)
assert "Invalid authentication credentials" in str(e)


def test_routing_wrong_url(monkeypatch, qv_circ, backend):
Expand All @@ -105,15 +104,11 @@ def test_routing_wrong_url(monkeypatch, qv_circ, backend):
ai_optimized_circuit = ai_optimize_lf.run(qv_circ)
pytest.fail("Error expected")
except Exception as e:
assert "Expecting value: line 1 column 1 (char 0)" in str(
e
)
assert "Expecting value: line 1 column 1 (char 0)" in str(e)
assert type(e).__name__ == "JSONDecodeError"


def test_routing_unexisting_url(
monkeypatch, qv_circ, backend
):
def test_routing_unexisting_url(monkeypatch, qv_circ, backend):
monkeypatch.undo()
ai_optimize_lf = PassManager(
[
Expand All @@ -129,7 +124,7 @@ def test_routing_unexisting_url(
except Exception as e:
print(e)
assert (
"Error: HTTPSConnectionPool(host=\\\'invented-domain-qiskit-transpiler-service-123.com\\\', port=443):"
"Error: HTTPSConnectionPool(host=\\'invented-domain-qiskit-transpiler-service-123.com\\', port=443):"
in str(e)
)
assert type(e).__name__ == "TranspilerError"

0 comments on commit 011aef3

Please sign in to comment.