@@ -43,19 +43,19 @@ def test_greet(
43
43
44
44
# Check number and names of parameters
45
45
assert len (params ) == 2 , "The function should take two arguments."
46
- assert (
47
- "name" in params and " age" in params
48
- ), "The function's parameters should be 'name' and 'age'."
46
+ assert "name" in params and "age" in params , (
47
+ "The function's parameters should be 'name' and ' age'."
48
+ )
49
49
50
50
# Check type hints for parameters
51
- assert all (
52
- p . annotation != inspect . Parameter . empty for p in params . values ()
53
- ), "The function's parameters should have type hints."
51
+ assert all (p . annotation != inspect . Parameter . empty for p in params . values ()), (
52
+ "The function's parameters should have type hints."
53
+ )
54
54
55
55
# Check return type hint
56
- assert (
57
- return_annotation != inspect . Signature . empty
58
- ), "The function's return value is missing the type hint."
56
+ assert return_annotation != inspect . Signature . empty , (
57
+ "The function's return value is missing the type hint."
58
+ )
59
59
60
60
# Test the return value
61
61
assert function_to_test (name , age ) == reference_greet (name , age )
@@ -80,15 +80,15 @@ def validate_basic_area_signature(function_to_test) -> None:
80
80
return_annotation = signature .return_annotation
81
81
82
82
assert function_to_test .__doc__ is not None , "The function is missing a docstring."
83
- assert (
84
- len ( params ) == 2
85
- ), "The function should take exactly two arguments (length and width)."
86
- assert all (
87
- p in params . keys () for p in [ " length" , " width" ]
88
- ), "The function's parameters should be 'length' and 'width'."
89
- assert all (
90
- p . annotation is float for p in params . values ()
91
- ), "Both parameters should be annotated as float."
83
+ assert len ( params ) == 2 , (
84
+ "The function should take exactly two arguments (length and width)."
85
+ )
86
+ assert all (p in params . keys () for p in [ "length" , "width" ]), (
87
+ "The function's parameters should be ' length' and ' width'."
88
+ )
89
+ assert all (p . annotation is float for p in params . values ()), (
90
+ "Both parameters should be annotated as float."
91
+ )
92
92
assert return_annotation is str , "The return type should be annotated as str."
93
93
94
94
@@ -134,24 +134,24 @@ def validate_metric_area_signature(function_to_test) -> None:
134
134
return_annotation = signature .return_annotation
135
135
136
136
assert function_to_test .__doc__ is not None , "The function is missing a docstring."
137
- assert (
138
- len ( params ) == 3
139
- ), "The function should take three arguments (length, width, and unit)."
140
- assert all (
141
- p in params . keys () for p in [ " length" , " width" , " unit" ]
142
- ), "The function's parameters should be 'length', 'width' and 'unit'."
143
- assert (
144
- params [ " length" ]. annotation is float
145
- ), "Parameter 'length' should be annotated as float."
146
- assert (
147
- params [ " width" ]. annotation is float
148
- ), "Parameter 'width' should be annotated as float."
149
- assert (
150
- params [ " unit" ]. annotation is str
151
- ), "Parameter 'unit' should be annotated as str."
152
- assert (
153
- params [ " unit" ]. default == "cm "
154
- ), "Parameter 'unit' should have a default value of 'cm'."
137
+ assert len ( params ) == 3 , (
138
+ "The function should take three arguments (length, width, and unit)."
139
+ )
140
+ assert all (p in params . keys () for p in [ "length" , "width" , "unit" ]), (
141
+ "The function's parameters should be ' length', ' width' and ' unit'."
142
+ )
143
+ assert params [ "length" ]. annotation is float , (
144
+ "Parameter ' length' should be annotated as float."
145
+ )
146
+ assert params [ "width" ]. annotation is float , (
147
+ "Parameter ' width' should be annotated as float."
148
+ )
149
+ assert params [ "unit" ]. annotation is str , (
150
+ "Parameter ' unit' should be annotated as str."
151
+ )
152
+ assert params [ "unit" ]. default == "cm" , (
153
+ "Parameter ' unit' should have a default value of 'cm'. "
154
+ )
155
155
assert return_annotation is str , "The return type should be annotated as str."
156
156
157
157
@@ -195,24 +195,24 @@ def validate_area_signature(function_to_test) -> None:
195
195
return_annotation = signature .return_annotation
196
196
197
197
assert function_to_test .__doc__ is not None , "The function is missing a docstring."
198
- assert (
199
- len ( params ) == 3
200
- ), "The function should take three arguments (length, width, and unit)."
201
- assert all (
202
- p in params . keys () for p in [ " length" , " width" , " unit" ]
203
- ), "The function's parameters should be 'length', 'width' and 'unit'."
204
- assert (
205
- params [ " length" ]. annotation is float
206
- ), "Parameter 'length' should be annotated as float."
207
- assert (
208
- params [ " width" ]. annotation is float
209
- ), "Parameter 'width' should be annotated as float."
210
- assert (
211
- params [ " unit" ]. annotation is str
212
- ), "Parameter 'unit' should be annotated as str."
213
- assert (
214
- params [ " unit" ]. default == "cm "
215
- ), "Parameter 'unit' should have a default value of 'cm'."
198
+ assert len ( params ) == 3 , (
199
+ "The function should take three arguments (length, width, and unit)."
200
+ )
201
+ assert all (p in params . keys () for p in [ "length" , "width" , "unit" ]), (
202
+ "The function's parameters should be ' length', ' width' and ' unit'."
203
+ )
204
+ assert params [ "length" ]. annotation is float , (
205
+ "Parameter ' length' should be annotated as float."
206
+ )
207
+ assert params [ "width" ]. annotation is float , (
208
+ "Parameter ' width' should be annotated as float."
209
+ )
210
+ assert params [ "unit" ]. annotation is str , (
211
+ "Parameter ' unit' should be annotated as str."
212
+ )
213
+ assert params [ "unit" ]. default == "cm" , (
214
+ "Parameter ' unit' should have a default value of 'cm'. "
215
+ )
216
216
assert return_annotation is str , "The return type should be annotated as str."
217
217
218
218
0 commit comments