@@ -150,7 +150,7 @@ async def lifespan_only_app(scope: Scope, receive: Receive, send: Send) -> None:
150
150
"accept" ,
151
151
[(None ), ("*/*" ), ("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8" )],
152
152
)
153
- async def test_quirks (accept : str ) -> None :
153
+ async def test_quirks_encode (accept : str ) -> None :
154
154
app = LLSDMiddleware (JSONResponse ({"message" : "Hello, world!" }), quirks = True )
155
155
156
156
async with httpx .AsyncClient (app = app , base_url = "http://testserver" ) as client :
@@ -166,6 +166,25 @@ async def test_quirks(accept: str) -> None:
166
166
assert llsd .parse_xml (r .content ) == {"message" : "Hello, world!" }
167
167
168
168
169
+ @pytest .mark .asyncio
170
+ async def test_quirks_decode ():
171
+ async def app (scope : Scope , receive : Receive , send : Send ) -> None :
172
+ request = Request (scope , receive = receive )
173
+ data = await request .json ()
174
+ message = data ["message" ]
175
+ text = f"message={ message !r} "
176
+
177
+ response = PlainTextResponse (text )
178
+ await response (scope , receive , send )
179
+
180
+ app = LLSDMiddleware (app , quirks = True )
181
+
182
+ async with httpx .AsyncClient (app = app , base_url = "http://testserver" ) as client :
183
+ r = await client .post ("/" , content = llsd .format_xml ({"message" : "Hello, world!" }))
184
+ assert r .status_code == 200
185
+ assert r .text == "message='Hello, world!'"
186
+
187
+
169
188
@pytest .mark .asyncio
170
189
@pytest .mark .parametrize (
171
190
"accept" ,
0 commit comments