Add a simple parser for content type specifications.

This commit is contained in:
Aldo Cortesi
2012-03-20 10:31:07 +13:00
parent bc3ba4c993
commit 2739cb4861
3 changed files with 39 additions and 0 deletions

View File

@@ -214,7 +214,18 @@ class u_parse_size(libpry.AutoTree):
libpry.raises(ValueError, utils.parse_size, "ak")
class u_parse_content_type(libpry.AutoTree):
def test_simple(self):
p = utils.parse_content_type
assert p("text/html") == ("text", "html", {})
assert p("text") == None
v = p("text/html; charset=UTF-8")
assert v == ('text', 'html', {'charset': 'UTF-8'})
tests = [
u_parse_content_type(),
uformat_timestamp(),
uisBin(),
uisXML(),