from multidict import CIMultiDict, MultiDict from re_assert import Matches from yarl import URL from aiohttp import helpers from aiohttp.helpers import is_expected_content_type IS_PYPY = platform.python_implementation() == "PyPy" # ------------------- parse_mimetype ---------------------------------- @pytest.mark.parametrize( "mimetype, expected", [ ("", helpers.MimeType("", "", "", MultiDict())), ("*", helpers.MimeType("*", "*", "", MultiDict())), ("application/json", helpers.MimeType("application", "json", "", MultiDict())), ( "application/json; charset=utf-8", helpers.MimeType("application", "json", "", MultiDict({"charset": "utf-8"})), ), ( """application/json; charset=utf-8;""", helpers.MimeType("application", "json", "", MultiDict({"charset": "utf-8"})), ), ( 'ApPlIcAtIoN/JSON;ChaRseT="UTF-8"',
import pytest from multidict import MultiDict from yarl import URL from aiohttp import helpers from aiohttp.helpers import is_expected_content_type IS_PYPY = platform.python_implementation() == 'PyPy' # ------------------- parse_mimetype ---------------------------------- @pytest.mark.parametrize( 'mimetype, expected', [('', helpers.MimeType('', '', '', MultiDict())), ('*', helpers.MimeType('*', '*', '', MultiDict())), ('application/json', helpers.MimeType('application', 'json', '', MultiDict())), ('application/json; charset=utf-8', helpers.MimeType('application', 'json', '', MultiDict({'charset': 'utf-8'}))), ('''application/json; charset=utf-8;''', helpers.MimeType('application', 'json', '', MultiDict({'charset': 'utf-8'}))), ('ApPlIcAtIoN/JSON;ChaRseT="UTF-8"', helpers.MimeType('application', 'json', '', MultiDict({'charset': 'UTF-8'}))), ('application/rss+xml', helpers.MimeType('application', 'rss', 'xml', MultiDict())), ('text/plain;base64',
import gc import os import tempfile from unittest import mock import pytest from yarl import URL from aiohttp import helpers from aiohttp.abc import AbstractAccessLogger # ------------------- parse_mimetype ---------------------------------- @pytest.mark.parametrize('mimetype, expected', [ ('', helpers.MimeType('', '', '', {})), ('*', helpers.MimeType('*', '*', '', {})), ('application/json', helpers.MimeType('application', 'json', '', {})), ('application/json; charset=utf-8', helpers.MimeType('application', 'json', '', {'charset': 'utf-8'})), ('''application/json; charset=utf-8;''', helpers.MimeType('application', 'json', '', {'charset': 'utf-8'})), ('ApPlIcAtIoN/JSON;ChaRseT="UTF-8"', helpers.MimeType('application', 'json', '', {'charset': 'UTF-8'})), ('application/rss+xml', helpers.MimeType('application', 'rss', 'xml', {})), ('text/plain;base64', helpers.MimeType('text', 'plain', '', {'base64': ''})) ]) def test_parse_mimetype(mimetype, expected): result = helpers.parse_mimetype(mimetype)