MCPcopy
hub / github.com/django/django / test_value_after_read

Method test_value_after_read

tests/requests_tests/tests.py:363–380  ·  view source on GitHub ↗

Construction of POST or body is not allowed after reading from request.

(self)

Source from the content-addressed store, hash-verified

361 self.assertEqual(request.read(), b"name=value")
362
363 def test_value_after_read(self):
364 """
365 Construction of POST or body is not allowed after reading
366 from request.
367 """
368 payload = FakePayload("name=value")
369 request = WSGIRequest(
370 {
371 "REQUEST_METHOD": "POST",
372 "CONTENT_TYPE": "application/x-www-form-urlencoded",
373 "CONTENT_LENGTH": len(payload),
374 "wsgi.input": payload,
375 }
376 )
377 self.assertEqual(request.read(2), b"na")
378 with self.assertRaises(RawPostDataException):
379 request.body
380 self.assertEqual(request.POST, {})
381
382 def test_non_ascii_POST(self):
383 payload = FakePayload(urlencode({"key": "España"}))

Callers

nothing calls this directly

Calls 3

FakePayloadClass · 0.90
WSGIRequestClass · 0.90
readMethod · 0.45

Tested by

no test coverage detected