3
# Tests for stuff in django.utils.text and other text munging util functions.
5
>>> from django.utils.text import *
7
### smart_split ###########################################################
8
>>> list(smart_split(r'''This is "a person" test.'''))
9
[u'This', u'is', u'"a person"', u'test.']
10
>>> print list(smart_split(r'''This is "a person's" test.'''))[2]
12
>>> print list(smart_split(r'''This is "a person\"s" test.'''))[2]
14
>>> list(smart_split('''"a 'one'''))
16
>>> print list(smart_split(r'''all friends' tests'''))[1]
19
### urlquote #############################################################
20
>>> from django.utils.http import urlquote, urlquote_plus
21
>>> urlquote(u'Paris & Orl\xe9ans')
22
u'Paris%20%26%20Orl%C3%A9ans'
23
>>> urlquote(u'Paris & Orl\xe9ans', safe="&")
24
u'Paris%20&%20Orl%C3%A9ans'
25
>>> urlquote_plus(u'Paris & Orl\xe9ans')
26
u'Paris+%26+Orl%C3%A9ans'
27
>>> urlquote_plus(u'Paris & Orl\xe9ans', safe="&")
28
u'Paris+&+Orl%C3%A9ans'
30
### cookie_date, http_date ###############################################
31
>>> from django.utils.http import cookie_date, http_date
34
'Mon, 01-Jan-2007 01:54:21 GMT'
36
'Mon, 01 Jan 2007 01:54:21 GMT'
38
### iri_to_uri ###########################################################
39
>>> from django.utils.encoding import iri_to_uri
40
>>> iri_to_uri(u'red%09ros\xe9#red')
42
>>> iri_to_uri(u'/blog/for/J\xfcrgen M\xfcnster/')
43
'/blog/for/J%C3%BCrgen%20M%C3%BCnster/'
44
>>> iri_to_uri(u'locations/%s' % urlquote_plus(u'Paris & Orl\xe9ans'))
45
'locations/Paris+%26+Orl%C3%A9ans'
47
iri_to_uri() is idempotent:
48
>>> iri_to_uri(iri_to_uri(u'red%09ros\xe9#red'))