From a14256aade963929743aa09e0834f5fc4072f772 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 26 Oct 2007 20:08:56 +0000 Subject: [PATCH] Committed missing file from [6608]. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6612 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/i18n/misc.py | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/regressiontests/i18n/misc.py diff --git a/tests/regressiontests/i18n/misc.py b/tests/regressiontests/i18n/misc.py new file mode 100644 index 00000000000..fa22fd05d3f --- /dev/null +++ b/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('') +[] + +"""