Skip to content

Commit

Permalink
Merge pull request #87 from qiboteam/format_err
Browse files Browse the repository at this point in the history
Coloring the `JobApiError` in red
  • Loading branch information
scarrazza authored Nov 12, 2024
2 parents 99609be + 0b3119d commit 419ee5c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/qibo_client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ class JobApiError(Exception):
def __init__(self, status_code: int, message: str):
self.status_code = status_code
self.message = message
self.displayed_message = f"[{self.status_code} Error] {self.message}"
self.displayed_message = f"\033[91m[{self.status_code} Error] {self.message}"
super().__init__(self.displayed_message)
2 changes: 1 addition & 1 deletion tests/test_qibo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_run_circuit_with_invalid_token(self, pass_version_check):
with pytest.raises(exceptions.JobApiError) as err:
self.obj.run_circuit(FAKE_CIRCUIT, FAKE_DEVICE, FAKE_NSHOTS)

expected_message = f"[404 Error] {message}"
expected_message = f"\033[91m[404 Error] {message}"
assert str(err.value) == expected_message

def test_run_circuit_with_job_post_error(self, pass_version_check):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_qibo_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_refresh_with_invalid_pid(self):
with pytest.raises(exceptions.JobApiError) as err:
self.obj.refresh()

expected_message = f"[404 Error] {response_json['detail']}"
expected_message = f"\033[91m[404 Error] {response_json['detail']}"
assert str(err.value) == expected_message

@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_get_request_with_404_error():
with pytest.raises(exceptions.JobApiError) as err:
utils.QiboApiRequest.get(endpoint)

expected_message = f"[{status_code} Error] {message}"
expected_message = f"\033[91m[{status_code} Error] {message}"
assert str(err.value) == expected_message


Expand Down Expand Up @@ -87,5 +87,5 @@ def test_post_request_with_404_error():
with pytest.raises(exceptions.JobApiError) as err:
utils.QiboApiRequest.post(endpoint)

expected_message = f"[{status_code} Error] {message}"
expected_message = f"\033[91m[{status_code} Error] {message}"
assert str(err.value) == expected_message

0 comments on commit 419ee5c

Please sign in to comment.