@@ -43,19 +43,19 @@ def test_greet(
4343
4444 # Check number and names of parameters
4545 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+ )
4949
5050 # 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+ )
5454
5555 # 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+ )
5959
6060 # Test the return value
6161 assert function_to_test (name , age ) == reference_greet (name , age )
@@ -80,15 +80,15 @@ def validate_basic_area_signature(function_to_test) -> None:
8080 return_annotation = signature .return_annotation
8181
8282 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+ )
9292 assert return_annotation is str , "The return type should be annotated as str."
9393
9494
@@ -134,24 +134,24 @@ def validate_metric_area_signature(function_to_test) -> None:
134134 return_annotation = signature .return_annotation
135135
136136 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+ )
155155 assert return_annotation is str , "The return type should be annotated as str."
156156
157157
@@ -195,24 +195,24 @@ def validate_area_signature(function_to_test) -> None:
195195 return_annotation = signature .return_annotation
196196
197197 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+ )
216216 assert return_annotation is str , "The return type should be annotated as str."
217217
218218
0 commit comments