Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Committed missing file from [6608].

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6612 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a14256aade963929743aa09e0834f5fc4072f772 1 parent 842a771
@jacobian jacobian authored
Showing with 57 additions and 0 deletions.
  1. +57 −0 tests/regressiontests/i18n/misc.py
View
57 tests/regressiontests/i18n/misc.py
@@ -0,0 +1,57 @@
+tests = """
+>>> from django.utils.translation.trans_real import parse_accept_lang_header
+>>> p = parse_accept_lang_header
+
+Good headers.
+>>> p('de')
+[('de', 1.0)]
+>>> p('en-AU')
+[('en-AU', 1.0)]
+>>> p('*;q=1.00')
+[('*', 1.0)]
+>>> p('en-AU;q=0.123')
+[('en-AU', 0.123)]
+>>> p('en-au;q=0.1')
+[('en-au', 0.10000000000000001)]
+>>> p('en-au;q=1.0')
+[('en-au', 1.0)]
+>>> p('da, en-gb;q=0.25, en;q=0.5')
+[('da', 1.0), ('en', 0.5), ('en-gb', 0.25)]
+>>> p('en-au-xx')
+[('en-au-xx', 1.0)]
+>>> p('de,en-au;q=0.75,en-us;q=0.5,en;q=0.25,es;q=0.125,fa;q=0.125')
+[('de', 1.0), ('en-au', 0.75), ('en-us', 0.5), ('en', 0.25), ('es', 0.125), ('fa', 0.125)]
+>>> p('*')
+[('*', 1.0)]
+>>> p('de;q=0.')
+[('de', 1.0)]
+>>> p('')
+[]
+
+Bad headers; should always return [].
+>>> p('en-gb;q=1.0000')
+[]
+>>> p('en;q=0.1234')
+[]
+>>> p('en;q=.2')
+[]
+>>> p('abcdefghi-au')
+[]
+>>> p('**')
+[]
+>>> p('en,,gb')
+[]
+>>> p('en-au;q=0.1.0')
+[]
+>>> p('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZ,en')
+[]
+>>> p('da, en-gb;q=0.8, en;q=0.7,#')
+[]
+>>> p('de;q=2.0')
+[]
+>>> p('de;q=0.a')
+[]
+>>> p('')
+[]
+
+"""
Please sign in to comment.
Something went wrong with that request. Please try again.