def test_empty(self): parsed = parse_option_header('text/plain; charset=""') self.assertEqual(parsed, ('text/plain', {'charset': ''}))
def test_quoted(self): parsed = parse_option_header('text/plain; charset="foo bar"') self.assertEqual(parsed, ('text/plain', {'charset': 'foo bar'}))
def test_multiple(self): parsed = parse_option_header('text/plain; foo=bar baz=qux') self.assertEqual(parsed, ('text/plain', {'foo': 'bar', 'baz': 'qux'}))
def test_iso8859_1(self): parsed = parse_option_header('text/plain; foo="bar\xfe"') self.assertEqual(parsed, ('text/plain', {'foo': 'bar\xfe'}))
def test_whitespace(self): parsed = parse_option_header('text/plain; charset=foo ') self.assertEqual(parsed, ('text/plain', {'charset': 'foo'}))
def test_basic(self): parsed = parse_option_header('text/plain; charset=foo') self.assertIsInstance(parsed, tuple) self.assertEqual(len(parsed), 2) self.assertEqual(parsed[0], 'text/plain') self.assertEqual(parsed[1], {'charset': 'foo'})
def test_plain(self): parsed = parse_option_header('text/plain') self.assertEqual(parsed, ('text/plain', {}))