Skip to content

Commit 0cbac3a

Browse files
Copilot4n4nd
andcommitted
Fix deprecated assertRaises msg parameter in tests
Co-authored-by: 4n4nd <22333506+4n4nd@users.noreply.github.com>
1 parent 91b9e76 commit 0cbac3a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

tests/test_prometheus_connect.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,22 @@ def test_get_metric_range_data_with_incorrect_input_types(self): # noqa D102
9393
chunk_size = timedelta(minutes=7)
9494
end_time = datetime.now() - timedelta(minutes=10)
9595

96-
with self.assertRaises(ValueError, msg="specified chunk_size is too big"):
96+
with self.assertRaises(ValueError):
9797
_ = self.pc.get_metric_range_data(
9898
metric_name="up",
9999
start_time=start_time,
100100
end_time=end_time,
101101
chunk_size=timedelta(minutes=30),
102102
)
103-
with self.assertRaises(TypeError, msg="start_time accepted invalid value type"):
103+
with self.assertRaises(TypeError):
104104
_ = self.pc.get_metric_range_data(
105105
metric_name="up", start_time="20m", end_time=end_time, chunk_size=chunk_size
106106
)
107-
with self.assertRaises(TypeError, msg="end_time accepted invalid value type"):
107+
with self.assertRaises(TypeError):
108108
_ = self.pc.get_metric_range_data(
109109
metric_name="up", start_time=start_time, end_time="10m", chunk_size=chunk_size
110110
)
111-
with self.assertRaises(TypeError, msg="chunk_size accepted invalid value type"):
111+
with self.assertRaises(TypeError):
112112
_ = self.pc.get_metric_range_data(
113113
metric_name="up", start_time=start_time, end_time=end_time, chunk_size="10m"
114114
)
@@ -125,7 +125,7 @@ def test_get_metric_aggregation(self): # noqa D102
125125
self.assertTrue(len(aggregated_values) > 0, "no values received after aggregating")
126126

127127
def test_get_metric_aggregation_with_incorrect_input_types(self): # noqa D102
128-
with self.assertRaises(TypeError, msg="operations accepted invalid value type"):
128+
with self.assertRaises(TypeError):
129129
_ = self.pc.get_metric_aggregation(query="up", operations="sum")
130130
def test_retry_on_error(self): # noqa D102
131131
retry = Retry(total=3, backoff_factor=0.1, status_forcelist=[400])
@@ -684,7 +684,7 @@ def test_get_metric_range_data_edge_cases(self): # noqa D102
684684
end_time = datetime.now()
685685

686686
# Test with ValueError for end_time before start_time
687-
with self.assertRaises(ValueError, msg="end_time must not be before start_time"):
687+
with self.assertRaises(ValueError):
688688
self.pc.get_metric_range_data(
689689
"up", start_time=end_time, end_time=start_time
690690
)
@@ -759,7 +759,7 @@ def test_get_metric_aggregation_with_invalid_operation(self): # noqa D102
759759
}
760760

761761
with self.mock_response(query_payload):
762-
with self.assertRaises(TypeError, msg="Invalid operation"):
762+
with self.assertRaises(TypeError):
763763
self.pc.get_metric_aggregation(query="up", operations=["invalid_operation"])
764764

765765
def test_get_metric_aggregation_with_no_results(self): # noqa D102

0 commit comments

Comments
 (0)