MCPcopy
hub / github.com/django/django / test_base64_invalid_upload

Method test_base64_invalid_upload

tests/file_uploads/tests.py:162–187  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

160 self._test_base64_upload("Big data" * 68000, encode=base64.encodebytes)
161
162 def test_base64_invalid_upload(self):
163 payload = client.FakePayload(
164 "\r\n".join(
165 [
166 "--" + client.BOUNDARY,
167 'Content-Disposition: form-data; name="file"; filename="test.txt"',
168 "Content-Type: application/octet-stream",
169 "Content-Transfer-Encoding: base64",
170 "",
171 ]
172 )
173 )
174 payload.write(b"\r\n!\r\n")
175 payload.write("--" + client.BOUNDARY + "--\r\n")
176 request = WSGIRequest(
177 {
178 "CONTENT_LENGTH": len(payload),
179 "CONTENT_TYPE": client.MULTIPART_CONTENT,
180 "PATH_INFO": "/echo_content/",
181 "REQUEST_METHOD": "POST",
182 "wsgi.input": payload,
183 }
184 )
185 msg = "Could not decode base64 data."
186 with self.assertRaisesMessage(MultiPartParserError, msg):
187 request.POST
188
189 def test_unicode_file_name(self):
190 with sys_tempfile.TemporaryDirectory() as temp_dir:

Callers

nothing calls this directly

Calls 4

writeMethod · 0.95
WSGIRequestClass · 0.90
assertRaisesMessageMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected