File: test_acceptparse.pyc

package info (click to toggle)
python-webob 1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,340 kB
  • ctags: 2,468
  • sloc: python: 13,433; makefile: 12
file content (108 lines) | stat: -rw-r--r-- 17,938 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

TiPc@sAddklZddklZddklZddklZddklZddklZddklZddkl	Z	dd	k
lZlZd
Z
dZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9S(:i(tRequest(tAccept(t
MIMEAccept(t	NilAccept(tNoAccept(taccept_property(tAcceptLanguage(t
AcceptCharset(teq_t
assert_raisescCs*ttiddgjptdS(Nsvalue1; q=0.1.2tvalue1i(R
i(tlistRtparsetAssertionError(((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_parse_accept_badqscCs*td}|idgjptdS(Ns	text/htmli(s	text/htmli(Rt_parsedR
(taccept((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_init_accept_content_typescCs0td}|iddd	gjptdS(
Nsiso-8859-5, unicode-1-1;q=0.8s
iso-8859-5isunicode-1-1g?s
iso-8859-1(s
iso-8859-5i(sunicode-1-1g?(s
iso-8859-1i(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_init_accept_accept_charsets	cCs0td}|idd	d
gjptdS(sm3.4 Character Sets
           [...]
           HTTP character sets are identified by case-insensitive tokens.sISO-8859-5, UNICODE-1-1;q=0.8s
iso-8859-5isunicode-1-1g?s
iso-8859-1N(s
iso-8859-5i(sunicode-1-1g?(s
iso-8859-1i(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt)test_init_accept_accept_charset_mixedcases	cCs*td}|idgjptdS(Ns
iso-8859-1i(s
iso-8859-1i(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt/test_init_accept_accept_charset_with_iso_8859_1"scCs*td}|idgjptdS(Nt*i(Ri(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt(test_init_accept_accept_charset_wildcard&scCs0td}|idd	d
gjptdS(Nsda, en-gb;q=0.8, en;q=0.7tdaisen-gbg?tengffffff?(sdai(sen-gbg?(sengffffff?(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt test_init_accept_accept_language*s	cCs-td}|iddgjptdS(Nsda, q, en-gb;q=0.8Risen-gbg?(sdai(sen-gbg?(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_init_accept_invalid_value0s	cCs-td}|iddgjptdS(Nsda, en-gb;q=fooRisen-gb(sdai(sen-gbi(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt test_init_accept_invalid_q_value6scCs*td}t|djptdS(Ns	text/htmls<Accept('text/html')>(RtreprR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_repr<scCs*td}t|djptdS(Ns	text/html(RtstrR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_str@scCsDtdidgdjptdtdjptdS(Ns
bar, *;q=0tfoos*;q=0(Rt
best_matchtNoneR
(((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_zero_qualityDs&cCs0d}t|}t||jptdS(Nstext/html;q=0.5(RRR
(tvalueR((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_str_with_q_not_1IscCs0d}t|}t||jptdS(Nstext/html;q=0.5, foo/bar(RRR
(R$R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt%test_accept_str_with_q_not_1_multipleNscCs^tdtd}t|djpt|td7}t|djptdS(Ns	text/htmlsfoo/barstext/html, foo/bars
bar/baz;q=0.5s!text/html, foo/bar, bar/baz;q=0.5(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_add_other_acceptSscCstd}|dg7}t|djpt|dg7}t|djpt|dd	g7}t|d
jptdS(
Ns	text/htmlsfoo/baristext/html, foo/barsbar/bazg?s!text/html, foo/bar, bar/baz;q=0.5s	she/bangss	the/houses7text/html, foo/bar, bar/baz;q=0.5, she/bangs, the/house(sfoo/bari(sbar/bazg?(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt$test_accept_add_other_list_of_tuplesYs

cCsftd}|hdd67}t|djpt|hdd67}t|djptdS(Ns	text/htmlisfoo/barstext/html, foo/barg?sbar/bazs!text/html, foo/bar, bar/baz;q=0.5(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_add_other_dictcs
cCs4td}|d7}t|djptdS(Ns	text/htmlt(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_add_other_empty_strjs
cCs4td}|d7}t|djptdS(NR*s	text/html(RRR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt'test_accept_with_no_value_add_other_stros
cCs$td}d|jptdS(Ns	text/html(RR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt
test_containstscCs$td}d|jptdS(Ns	text/htmlsfoo/bar(RR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_contains_notxscCsVtd}|iddjpttd}|iddjptdS(Ns	text/htmlistext/html;q=0.5g?(RtqualityR
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_quality|scCs-td}|iddjptdS(Ns	text/htmlsfoo/bar(RR/R"R
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_quality_not_foundscCstd}|iddgdjpt|iddgdjpt|iddgdjpt|idd	gdjpttt|idgdS(
Nstext/html, foo/bars	text/htmlsfoo/barg?g?stext/*(sfoo/barg?(sfoo/barg?(s	text/htmlg?(RR!R
R	t
ValueError(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_best_matchs##		cCsbtd}|iddgdjpttd}|iddgdjptdS(Nstext/html, foo/bar;q=0.5s	text/htmlsfoo/barstext/html;q=0.5, foo/bar(RR!R
(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt test_best_match_with_one_lower_qs#cCstd}|iddgdjpttd}dt|jptdt|jptdt|jpt|iddgdjptdS(	Ns*text/html, foo/bar;q=0.55, baz/gort;q=0.59s	text/htmlsfoo/bars3text/html;q=0.5, foo/bar;q=0.586, baz/gort;q=0.5966sbaz/gort;q=0.597sfoo/bar;q=0.586stext/html;q=0.5sbaz/gort(RR!R
R(R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_best_match_with_complex_qs#cCsRx1dddgD] }dt|jptqWdtdjptdS(NRs	text/htmls	TEXT/HTMLsfoo/bar(RR
(tmask((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_matchscCsx@d
ddd
ddgD]&\}}|t|jptqWx:ddddgD]&\}}|t|jptqVWdS(NRRtDARsen-gbten_GBsen-ussfr-frtfr(Rsda(sdaR8(sensen-gb(sen-gbsen-gb(sen-gbsen(sen-gbsen_GB(sen-gbsen-us(sen-gbsfr-fr(sen-gbsfr(sensfr-fr(RR
(R6tlang((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_match_langs cCsft}tt|d|ptt|djpt|iddjptdS(Ns/<NilAccept: <class 'webob.acceptparse.Accept'>>R*tdummyi(RRRR
RR/(t	nilaccept((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_nils	cCst}td}|||jpt||}t||ipt|idjpt|d}t||ipt|idjptdS(Ns	text/htmlR*R (RRR
t
isinstancet	__class__theader_value(R>Rt
new_accept((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_nil_adds	

cCsRt}td}td||iptd|idjptdS(Ns	text/htmlR (RRR@RAR
RB(R>R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt
test_nil_radds	cCs6t}td}|i||jptdS(Ns	text/html(RRt__radd__R
(R>R((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_nil_radd_masterclasss	cCs!t}d|jptdS(Ntanything(RR
(R>((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_nil_containss	cCst}|iddgdjpt|iddgdjpt|id	d
gdjpt|iddgdjpt|iddgdtdjpt|id
dgdtdjpt|igdddjptdS(NR tbarig?t
default_matchtfallback(sfooi(sbarg?(sfoog?(sbari(sfoog?(sfoog?(sfoog?(RR!R
tTruetFalse(R>((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_nil_best_matchs	####cCsdtjptdS(Ns
text/plain(RR
(((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_noaccept_containsscCs.td}|idgjpttd}|id
dgjpttd}|idgjpttd}|idgjpttd}|igjpttd	}|igjpttd
}|igjpttd}|idgjptdS(Ns	image/jpgisimage/png, image/jpg;q=0.5s	image/pngg?simage, image/jpg;q=0.5s*/*s*/pngs	image/pn*s	imag*/pngsimage/*(s	image/jpgi(s	image/pngi(s	image/jpgg?(s	image/jpgg?(s*/*i(simage/*i(RRR
(t
mimeaccept((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_mime_inits cCsEtd}|ipttd}|iptdS(Ns	image/jpgsimage/jpg, text/html(Rtaccept_htmlR
(RQ((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_htmlscCstd}|iddpt|iddpt|iddpt|iddpttt|idddS(Ns	image/jpgsimage/*s*/*s	text/html(Rt_matchR
R	R2(RQ((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt
test_matchscCs0td}|idgdjptdS(Nstext/html, *; q=.2, */*; q=.2sapplication/json(RR!R
(RQ((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_jsonscCs$td}|iptdS(s~3.7 Media Types
           [...]
           The type, subtype, and parameter attribute names are case-
           insensitive.s	text/HtMlN(RRSR
(RQ((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_mixedcasescCsvtd}|idgdjpt|idgdjpt|idddgdjptdS(Ns0image/jpg; q=.2, Image/pNg; Q=.4, image/*; q=.05s	Image/JpGs
image/Tiffs	image/PnGs	image/jpg(RR!R
(RQ((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_match_mixedcase s  cCs0td}|id	d
dgjptdS(skThe relative-quality-factor "q" parameter is defined as an exact string
       in "14.1 Accept" BNF grammars0image/jpg; q=.4, Image/pNg; Q=.2, image/*; q=.05s	image/jpgg?s	image/pngisimage/*g?N(s	image/jpgg?(s	image/pngi(simage/*g?(RRR
(RQ((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_match_uppercase_q&scCsXtdd}tiddhdd6}|i|dt|i|iddS(NsAccept-Charsets14.2t/tenvirontenvvaltenvkeytval(RRtblanktfsetRtfgetRB(tdesctreq((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_property_fget.scCs>tdd}tid}tt|i|tdS(NsAccept-Charsets14.2R[(RRR`RttypeRbR(RcRd((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_property_fget_nil4scCsXtdd}tiddhdd6}|i|dt|i|iddS(NsAccept-Charsets14.2R[R\R]R^tbaz(RRR`RaRRbRB(RcRd((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_property_fset9scCsBtiddhdd6}ddg|_t|iiddS(NR[R\R]R^sutf-8slatin-11sutf-8, latin-11, iso-8859-1(RR`taccept_charsetRRB(Rd((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt%test_accept_property_fset_acceptclass?scCstdd}tiddhdd6}|i|d|i|idjpt|i|tt	|i|t
dS(NsAccept-Charsets14.2R[R\R]R^R_(RRR`RaRbRBR
tfdelRRfR(RcRd((s5/home/chrism/projects/webob/tests/test_acceptparse.pyttest_accept_property_fdelDs 
N(<t
webob.requestRtwebob.acceptparseRRRRRRRt
nose.toolsRR	RRRRRRRRRRRR#R%R&R'R(R)R+R,R-R.R0R1R3R4R5R7R<R?RDRERGRIRORPRRRTRVRWRXRYRZReRgRiRkRm(((s5/home/chrism/projects/webob/tests/test_acceptparse.pyt<module>sn