ref: Use TypeError instead of ValueError when relevant (TRY004) (#4045)
Use TypeError instead of ValueError when relevant (TRY004)
This commit is contained in:
parent
12a381a3fa
commit
ba6838c13c
34 changed files with 56 additions and 54 deletions
|
|
@ -76,8 +76,8 @@ class TestCreateStateModel:
|
|||
assert state_instance.field_two == 123
|
||||
|
||||
# Raises ValueError for invalid field type in tuple-based definitions
|
||||
def test_raise_valueerror_for_invalid_field_type_in_tuple(self):
|
||||
with pytest.raises(ValueError, match="Invalid type for field invalid_field"):
|
||||
def test_raise_typeerror_for_invalid_field_type_in_tuple(self):
|
||||
with pytest.raises(TypeError, match="Invalid type for field invalid_field"):
|
||||
create_state_model(invalid_field=("not_a_type", "default"))
|
||||
|
||||
# Raises ValueError for unsupported value types in keyword arguments
|
||||
|
|
|
|||
|
|
@ -24,17 +24,17 @@ def test_gauge(opentelemetry_instance):
|
|||
|
||||
|
||||
def test_gauge_with_counter_method(opentelemetry_instance):
|
||||
with pytest.raises(ValueError, match="Metric 'file_uploads' is not a counter"):
|
||||
with pytest.raises(TypeError, match="Metric 'file_uploads' is not a counter"):
|
||||
opentelemetry_instance.increment_counter(metric_name="file_uploads", value=1, labels=fixed_labels)
|
||||
|
||||
|
||||
def test_gauge_with_historgram_method(opentelemetry_instance):
|
||||
with pytest.raises(ValueError, match="Metric 'file_uploads' is not a histogram"):
|
||||
with pytest.raises(TypeError, match="Metric 'file_uploads' is not a histogram"):
|
||||
opentelemetry_instance.observe_histogram("file_uploads", 1, fixed_labels)
|
||||
|
||||
|
||||
def test_gauge_with_up_down_counter_method(opentelemetry_instance):
|
||||
with pytest.raises(ValueError, match="Metric 'file_uploads' is not an up down counter"):
|
||||
with pytest.raises(TypeError, match="Metric 'file_uploads' is not an up down counter"):
|
||||
opentelemetry_instance.up_down_counter("file_uploads", 1, labels=fixed_labels)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue