Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #3036 -- Fixed some doctest strings that were failing. Thanks t…

…o pterk for the original patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6268 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 84e824fbbf7b1c90e0d6191e8e69577cfce0664b 1 parent 671a835
Russell Keith-Magee authored September 15, 2007
6  django/core/serializers/__init__.py
@@ -3,9 +3,9 @@
3 3
 
4 4
 Usage::
5 5
 
6  
-    >>> from django.core import serializers
7  
-    >>> json = serializers.serialize("json", some_query_set)
8  
-    >>> objects = list(serializers.deserialize("json", json))
  6
+    from django.core import serializers
  7
+    json = serializers.serialize("json", some_query_set)
  8
+    objects = list(serializers.deserialize("json", json))
9 9
 
10 10
 To add your own serializers, use the SERIALIZATION_MODULES setting::
11 11
 
17  django/core/validators.py
@@ -405,12 +405,17 @@ def __call__(self, field_data, all_data):
405 405
 
406 406
 class IsAPowerOf(object):
407 407
     """
408  
-    >>> v = IsAPowerOf(2)
409  
-    >>> v(4, None)
410  
-    >>> v(8, None)
411  
-    >>> v(16, None)
412  
-    >>> v(17, None)
413  
-    django.core.validators.ValidationError: ['This value must be a power of 2.']
  408
+    Usage: If you create an instance of the IsPowerOf validator:
  409
+        v = IsAPowerOf(2)
  410
+    
  411
+    The following calls will succeed:
  412
+        v(4, None) 
  413
+        v(8, None)
  414
+        v(16, None)
  415
+    
  416
+    But this call:
  417
+        v(17, None)
  418
+    will raise "django.core.validators.ValidationError: ['This value must be a power of 2.']"
414 419
     """
415 420
     def __init__(self, power_of):
416 421
         self.power_of = power_of
27  django/template/__init__.py
@@ -34,14 +34,8 @@
34 34
 
35 35
 Sample code:
36 36
 
37  
->>> import template
38  
->>> s = '''
39  
-... <html>
40  
-... {% if test %}
41  
-...     <h1>{{ varvalue }}</h1>
42  
-... {% endif %}
43  
-... </html>
44  
-... '''
  37
+>>> from django import template
  38
+>>> s = u'<html>{% if test %}<h1>{{ varvalue }}</h1>{% endif %}</html>'
45 39
 >>> t = template.Template(s)
46 40
 
47 41
 (t is now a compiled template, and its render() method can be called multiple
@@ -49,10 +43,10 @@
49 43
 
50 44
 >>> c = template.Context({'test':True, 'varvalue': 'Hello'})
51 45
 >>> t.render(c)
52  
-'\n<html>\n\n    <h1>Hello</h1>\n\n</html>\n'
  46
+u'<html><h1>Hello</h1></html>'
53 47
 >>> c = template.Context({'test':False, 'varvalue': 'Hello'})
54 48
 >>> t.render(c)
55  
-'\n<html>\n\n</html>\n'
  49
+u'<html></html>'
56 50
 """
57 51
 import re
58 52
 from inspect import getargspec
@@ -529,10 +523,11 @@ class FilterExpression(object):
529 523
     and return a list of tuples of the filter name and arguments.
530 524
     Sample:
531 525
         >>> token = 'variable|default:"Default value"|date:"Y-m-d"'
532  
-        >>> p = FilterParser(token)
533  
-        >>> p.filters
534  
-        [('default', 'Default value'), ('date', 'Y-m-d')]
535  
-        >>> p.var
  526
+        >>> p = Parser('')
  527
+        >>> fe = FilterExpression(token, p)
  528
+        >>> len(fe.filters)
  529
+        2
  530
+        >>> fe.var
536 531
         'variable'
537 532
 
538 533
     This class should never be instantiated outside of the
@@ -647,7 +642,7 @@ def resolve_variable(path, context):
647 642
 
648 643
     >>> c = {'article': {'section':'News'}}
649 644
     >>> resolve_variable('article.section', c)
650  
-    'News'
  645
+    u'News'
651 646
     >>> resolve_variable('article', c)
652 647
     {'section': 'News'}
653 648
     >>> class AClass: pass
@@ -655,7 +650,7 @@ def resolve_variable(path, context):
655 650
     >>> c.article = AClass()
656 651
     >>> c.article.section = 'News'
657 652
     >>> resolve_variable('article.section', c)
658  
-    'News'
  653
+    u'News'
659 654
 
660 655
     (The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.')
661 656
     """
16  django/utils/datastructures.py
@@ -238,22 +238,20 @@ class DotExpandedDict(dict):
238 238
     may contain dots to specify inner dictionaries. It's confusing, but this
239 239
     example should make sense.
240 240
 
241  
-    >>> d = DotExpandedDict({'person.1.firstname': ['Simon'],
242  
-            'person.1.lastname': ['Willison'],
243  
-            'person.2.firstname': ['Adrian'],
  241
+    >>> d = DotExpandedDict({'person.1.firstname': ['Simon'], \
  242
+            'person.1.lastname': ['Willison'], \
  243
+            'person.2.firstname': ['Adrian'], \
244 244
             'person.2.lastname': ['Holovaty']})
245 245
     >>> d
246  
-    {'person': {'1': {'lastname': ['Willison'], 'firstname': ['Simon']},
247  
-    '2': {'lastname': ['Holovaty'], 'firstname': ['Adrian']}}}
  246
+    {'person': {'1': {'lastname': ['Willison'], 'firstname': ['Simon']}, '2': {'lastname': ['Holovaty'], 'firstname': ['Adrian']}}}
248 247
     >>> d['person']
249  
-    {'1': {'firstname': ['Simon'], 'lastname': ['Willison'],
250  
-    '2': {'firstname': ['Adrian'], 'lastname': ['Holovaty']}
  248
+    {'1': {'lastname': ['Willison'], 'firstname': ['Simon']}, '2': {'lastname': ['Holovaty'], 'firstname': ['Adrian']}}
251 249
     >>> d['person']['1']
252  
-    {'firstname': ['Simon'], 'lastname': ['Willison']}
  250
+    {'lastname': ['Willison'], 'firstname': ['Simon']}
253 251
 
254 252
     # Gotcha: Results are unpredictable if the dots are "uneven":
255 253
     >>> DotExpandedDict({'c.1': 2, 'c.2': 3, 'c': 1})
256  
-    >>> {'c': 1}
  254
+    {'c': 1}
257 255
     """
258 256
     def __init__(self, key_to_list_mapping):
259 257
         for k, v in key_to_list_mapping.items():
1  django/utils/feedgenerator.py
@@ -3,6 +3,7 @@
3 3
 
4 4
 Sample usage:
5 5
 
  6
+>>> from django.utils import feedgenerator
6 7
 >>> feed = feedgenerator.Rss201rev2Feed(
7 8
 ...     title=u"Poynter E-Media Tidbits",
8 9
 ...     link=u"http://www.poynter.org/column.asp?id=31",

0 notes on commit 84e824f

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