'Testing HTTP header parsing. First, we test that we can parse the
values according to the spec (and that we extract all the pieces in
the right order).'

def test_parse_spec_http_header(self):

    p = trans_real.parse_accept_lang_header
    self.assertEqual([('de', 1.0)], p('de'))
    self.assertEqual([('en-au', 1.0)], p('en-AU'))
    self.assertEqual([('es-419', 1.0)], p('es-419'))
    self.assertEqual([('*', 1.0)], p('*;q=1.00'))
    self.assertEqual([('en-au', 0.123)], p('en-AU;q=0.123'))
    self.assertEqual([('en-au', 0.5)], p('en-au;q=0.5'))
    self.assertEqual([('en-au', 1.0)], p('en-au;q=1.0'))
    self.assertEqual([('da', 1.0), ('en', 0.5), ('en-gb', 0.25)], p('da,    en-gb;q=0.25,    en;q=0.5'))
    self.assertEqual([('en-au-xx', 1.0)], p('en-au-xx'))
    self.assertEqual([('de', 1.0), ('en-au', 0.75), ('en-us', 0.5), ('en', 0.25), ('es', 0.125), ('fa', 0.125)], p('de,en-au;q=0.75,en-us;q=0.5,en;q=0.25,es;q=0.125,fa;q=0.125'))
    self.assertEqual([('*', 1.0)], p('*'))
    self.assertEqual([('de', 0.0)], p('de;q=0.'))
    self.assertEqual([('en', 1.0), ('*', 0.5)], p('en;    q=1.0,    *    ;    q=0.5'))
    self.assertEqual([('en', 1.0)], p('en;    q=1,'))
    self.assertEqual([], p(''))
    self.assertEqual([], p('en-gb;q=1.0000'))
    self.assertEqual([], p('en;q=0.1234'))
    self.assertEqual([], p('en;q=.2'))
    self.assertEqual([], p('abcdefghi-au'))
    self.assertEqual([], p('**'))
    self.assertEqual([], p('en,,gb'))
    self.assertEqual([], p('en-au;q=0.1.0'))
    self.assertEqual([], p('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZ,en'))
    self.assertEqual([], p('da,    en-gb;q=0.8,    en;q=0.7,#'))
    self.assertEqual([], p('de;q=2.0'))
    self.assertEqual([], p('de;q=0.a'))
    self.assertEqual([], p('12-345'))
    self.assertEqual([], p(''))
    self.assertEqual([], p('en;q=1e0'))
