@@ -140,32 +140,30 @@ def _get_body_validator(self, content_type: str) -> Callable | None:
140140 except ValueError :
141141 return None
142142
143- def _extract_format_and_spec (
144- self , body_spec : Any , content_type : str
145- ) -> tuple [ContentFormat , Any ]:
143+ def _extract_format_and_spec (self , body_spec : Any ) -> tuple [ContentFormat , Any ]:
146144 """
147145 Extracts the format and spec from the body spec.
148146
149147 Args:
150148 body_spec: The body spec to extract from.
151- content_type: The content-type string.
152149
153150 Returns:
154151 A tuple containing the format and the spec.
155152
156153 Raises:
157- AssertionError: If the content-type is not supported.
154+ AssertionError: If the body_spec is not a dict with one of
155+ {ContentFormat} keys (json, xml, or text).
156+
158157 """
159158 if isinstance (body_spec , dict ):
160159 for fmt in ContentFormat :
161160 if fmt in body_spec :
162161 return fmt , body_spec [fmt ]
163162
164- try :
165- fmt = ContentFormat .from_mime_type (content_type )
166- return fmt , body_spec
167- except ValueError :
168- raise AssertionError (f"Unsupported content-type: { content_type } " )
163+ raise AssertionError (
164+ f"Body spec must be a dict with one of { list (ContentFormat )} keys, "
165+ f"got: { type (body_spec ).__name__ } "
166+ )
169167
170168 def _validate_body (self , body_format : ContentFormat , body_spec : Any ) -> None :
171169 """
@@ -195,6 +193,5 @@ def check_expectations(self) -> None:
195193 if body_spec is None :
196194 return
197195
198- content_type = get_content_type (self .response .headers .get ("Content-Type" , "" ))
199- body_format , body_spec = self ._extract_format_and_spec (body_spec , content_type )
196+ body_format , body_spec = self ._extract_format_and_spec (body_spec )
200197 self ._validate_body (body_format , body_spec )
0 commit comments