Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refs #7297 -- Corrected some doctest strings internal to the utils.te…

…xt module. Thanks, akaihola.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7581 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0586239660892f4a9fc4301a9c913241c457c876 1 parent 0433ffa
Russell Keith-Magee authored June 06, 2008

Showing 1 changed file with 13 additions and 9 deletions. Show diff stats Hide diff stats

  1. 22  django/utils/text.py
22  django/utils/text.py
@@ -118,7 +118,7 @@ def get_valid_filename(s):
118 118
     spaces are converted to underscores; and all non-filename-safe characters
119 119
     are removed.
120 120
     >>> get_valid_filename("john's portrait in 2004.jpg")
121  
-    'johns_portrait_in_2004.jpg'
  121
+    u'johns_portrait_in_2004.jpg'
122 122
     """
123 123
     s = force_unicode(s).strip().replace(' ', '_')
124 124
     return re.sub(r'[^-A-Za-z0-9_.]', '', s)
@@ -127,15 +127,15 @@ def get_valid_filename(s):
127 127
 def get_text_list(list_, last_word=ugettext_lazy(u'or')):
128 128
     """
129 129
     >>> get_text_list(['a', 'b', 'c', 'd'])
130  
-    'a, b, c or d'
  130
+    u'a, b, c or d'
131 131
     >>> get_text_list(['a', 'b', 'c'], 'and')
132  
-    'a, b and c'
  132
+    u'a, b and c'
133 133
     >>> get_text_list(['a', 'b'], 'and')
134  
-    'a and b'
  134
+    u'a and b'
135 135
     >>> get_text_list(['a'])
136  
-    'a'
  136
+    u'a'
137 137
     >>> get_text_list([])
138  
-    ''
  138
+    u''
139 139
     """
140 140
     if len(list_) == 0: return u''
141 141
     if len(list_) == 1: return force_unicode(list_[0])
@@ -198,14 +198,18 @@ def fix(match):
198 198
 
199 199
 smart_split_re = re.compile('("(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|[^\\s]+)')
200 200
 def smart_split(text):
201  
-    """
  201
+    r"""
202 202
     Generator that splits a string by spaces, leaving quoted phrases together.
203 203
     Supports both single and double quotes, and supports escaping quotes with
204 204
     backslashes. In the output, strings will keep their initial and trailing
205 205
     quote marks.
206 206
 
207  
-    >>> list(smart_split('This is "a person\'s" test.'))
208  
-    ['This', 'is', '"a person\'s"', 'test.']
  207
+    >>> list(smart_split(r'This is "a person\'s" test.'))
  208
+    [u'This', u'is', u'"a person\\\'s"', u'test.']
  209
+   	>>> list(smart_split(r"Another 'person\'s' test.")) 
  210
+   	[u'Another', u"'person's'", u'test.']
  211
+   	>>> list(smart_split(r'A "\"funky\" style" test.')) 
  212
+   	[u'A', u'""funky" style"', u'test.']
209 213
     """
210 214
     text = force_unicode(text)
211 215
     for bit in smart_split_re.finditer(text):

0 notes on commit 0586239

Please sign in to comment.
Something went wrong with that request. Please try again.