~ubuntu-branches/ubuntu/jaunty/python-django/jaunty

« back to all changes in this revision

Viewing changes to tests/regressiontests/text/tests.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant, Eddy Mulyono
  • Date: 2008-09-16 12:18:47 UTC
  • mfrom: (1.1.5 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080916121847-mg225rg5mnsdqzr0
Tags: 1.0-1ubuntu1
* Merge from Debian (LP: #264191), remaining changes:
  - Run test suite on build.

[Eddy Mulyono]
* Update patch to workaround network test case failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# coding: utf-8
 
2
r"""
 
3
# Tests for stuff in django.utils.text and other text munging util functions.
 
4
 
 
5
>>> from django.utils.text import *
 
6
 
 
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]
 
11
"a person's"
 
12
>>> print list(smart_split(r'''This is "a person\"s" test.'''))[2]
 
13
"a person"s"
 
14
>>> list(smart_split('''"a 'one'''))
 
15
[u'"a', u"'one"]
 
16
>>> print list(smart_split(r'''all friends' tests'''))[1]
 
17
friends'
 
18
 
 
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'
 
29
 
 
30
### cookie_date, http_date ###############################################
 
31
>>> from django.utils.http import cookie_date, http_date
 
32
>>> t = 1167616461.0
 
33
>>> cookie_date(t)
 
34
'Mon, 01-Jan-2007 01:54:21 GMT'
 
35
>>> http_date(t)
 
36
'Mon, 01 Jan 2007 01:54:21 GMT'
 
37
 
 
38
### iri_to_uri ###########################################################
 
39
>>> from django.utils.encoding import iri_to_uri
 
40
>>> iri_to_uri(u'red%09ros\xe9#red')
 
41
'red%09ros%C3%A9#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'
 
46
 
 
47
iri_to_uri() is idempotent:
 
48
>>> iri_to_uri(iri_to_uri(u'red%09ros\xe9#red'))
 
49
'red%09ros%C3%A9#red'
 
50
"""