MCPcopy
hub / github.com/django/django / test_basic

Method test_basic

tests/utils_tests/test_http.py:442–484  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

440
441class ParseHeaderParameterTests(unittest.TestCase):
442 def test_basic(self):
443 tests = [
444 ("", ("", {})),
445 (None, ("", {})),
446 ("text/plain", ("text/plain", {})),
447 ("text/vnd.just.made.this.up ; ", ("text/vnd.just.made.this.up", {})),
448 ("text/plain;charset=us-ascii", ("text/plain", {"charset": "us-ascii"})),
449 (
450 'text/plain ; charset="us-ascii"',
451 ("text/plain", {"charset": "us-ascii"}),
452 ),
453 (
454 'text/plain ; charset="us-ascii"; another=opt',
455 ("text/plain", {"charset": "us-ascii", "another": "opt"}),
456 ),
457 (
458 'attachment; filename="silly.txt"',
459 ("attachment", {"filename": "silly.txt"}),
460 ),
461 (
462 'attachment; filename="strange;name"',
463 ("attachment", {"filename": "strange;name"}),
464 ),
465 (
466 'attachment; filename="strange;name";size=123;',
467 ("attachment", {"filename": "strange;name", "size": "123"}),
468 ),
469 (
470 'attachment; filename="strange;name";;;;size=123;;;',
471 ("attachment", {"filename": "strange;name", "size": "123"}),
472 ),
473 (
474 'form-data; name="files"; filename="fo\\"o;bar"',
475 ("form-data", {"name": "files", "filename": 'fo"o;bar'}),
476 ),
477 (
478 'form-data; name="files"; filename="\\"fo\\"o;b\\\\ar\\""',
479 ("form-data", {"name": "files", "filename": '"fo"o;b\\ar"'}),
480 ),
481 ]
482 for header, expected in tests:
483 with self.subTest(header=header):
484 self.assertEqual(parse_header_parameters(header), expected)
485
486 def test_rfc2231_parsing(self):
487 test_data = (

Callers

nothing calls this directly

Calls 1

parse_header_parametersFunction · 0.90

Tested by

no test coverage detected