Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ct = "text/plain; charset=utf-8"
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {"charset": "utf-8"}
ct = "text/plain; "
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {}
ct = "text/plain; asdfasdf"
with pytest.raises(ValueError):
mt, st, opts = utils.parse_content_type(ct)
def test_parse_content_type():
ct = "text/plain"
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {}
ct = "text/plain; charset=utf-8"
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {"charset": "utf-8"}
ct = "text/plain; "
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {}
ct = "text/plain; asdfasdf"
with pytest.raises(ValueError):
mt, st, opts = utils.parse_content_type(ct)
def test_parse_content_type():
ct = "text/plain"
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {}
ct = "text/plain; charset=utf-8"
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {"charset": "utf-8"}
ct = "text/plain; "
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {}
def test_parse_content_type():
ct = "text/plain"
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {}
ct = "text/plain; charset=utf-8"
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {"charset": "utf-8"}
ct = "text/plain; "
mt, st, opts = utils.parse_content_type(ct)
assert mt == "text"
assert st == "plain"
assert opts == {}
ct = "text/plain; asdfasdf"
with pytest.raises(ValueError):
mt, st, opts = utils.parse_content_type(ct)