From c10cec52bf41b9cb461536637e124d66db69338b Mon Sep 17 00:00:00 2001 From: BrunoLiegiBastonLiegi Date: Thu, 7 Nov 2024 15:51:13 +0100 Subject: [PATCH 1/2] feat: coloring the error in red --- src/qibo_client/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qibo_client/exceptions.py b/src/qibo_client/exceptions.py index 671bd40..b26fc6f 100644 --- a/src/qibo_client/exceptions.py +++ b/src/qibo_client/exceptions.py @@ -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) From 0b3119dbeb63245f321639278b61397ec280f18d Mon Sep 17 00:00:00 2001 From: BrunoLiegiBastonLiegi Date: Thu, 7 Nov 2024 15:56:33 +0100 Subject: [PATCH 2/2] fix: fix tests --- tests/test_qibo_client.py | 2 +- tests/test_qibo_job.py | 2 +- tests/test_utils.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_qibo_client.py b/tests/test_qibo_client.py index dd52af0..204a1de 100644 --- a/tests/test_qibo_client.py +++ b/tests/test_qibo_client.py @@ -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): diff --git a/tests/test_qibo_job.py b/tests/test_qibo_job.py index 9b81aee..e618c9f 100644 --- a/tests/test_qibo_job.py +++ b/tests/test_qibo_job.py @@ -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( diff --git a/tests/test_utils.py b/tests/test_utils.py index d075df5..6d1a0dc 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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 @@ -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