Skip to content

Commit

Permalink
Small formatting changes to model unit tests to make them look better…
Browse files Browse the repository at this point in the history
… in the model examples online

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3030 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed May 31, 2006
1 parent 3daae59 commit a846155
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/modeltests/custom_methods/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
3. Giving models custom methods and custom managers
3. Giving models custom methods
Any method you add to a model will be available to instances.
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/modeltests/m2m_and_m2o/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
27. Many-to-many and many-to-one relationships to the same table.
27. Many-to-many and many-to-one relationships to the same table
This is a response to bug #1535
Expand All @@ -16,7 +16,7 @@ class Issue(models.Model):
client = models.ForeignKey(User, related_name='test_issue_client')
def __repr__(self):
return "<Issue %d>" % (self.num,)

class Meta:
ordering = ('num',)

Expand Down
25 changes: 12 additions & 13 deletions tests/modeltests/pagination/models.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
"""
20. Object Pagination
Django provides a framework for paginating a list of objects in a few.
This is often useful for dividing search results or long lists of objects
in to easily readable pages.
28. Object pagination
Django provides a framework for paginating a list of objects in a few lines
of code. This is often useful for dividing search results or long lists of
objects into easily readable pages.
"""

from django.db import models

class Article(models.Model):
headline = models.CharField(maxlength=100, default='Default headline')
pub_date = models.DateTimeField()

def __repr__(self):
return self.headline
return self.headline

API_TESTS = """
# prepare a list of objects for pagination
>>> from datetime import datetime
Expand All @@ -34,8 +33,8 @@ def __repr__(self):
>>> paginator.pages
2
# get the first page (zero-based)
>>> paginator.get_page(0)
# get the first page (zero-based)
>>> paginator.get_page(0)
[Article 1, Article 2, Article 3, Article 4, Article 5]
# get the second page
Expand All @@ -45,7 +44,7 @@ def __repr__(self):
# does the first page have a next or previous page?
>>> paginator.has_next_page(0)
True
>>> paginator.has_previous_page(0)
False
Expand All @@ -55,5 +54,5 @@ def __repr__(self):
>>> paginator.has_previous_page(1)
True
"""
2 changes: 1 addition & 1 deletion tests/modeltests/transactions/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
XXX. Transactions
15. Transactions
Django handles transactions in three different ways. The default is to commit
each transaction upon a write, but you can decorate a function to get
Expand Down
4 changes: 3 additions & 1 deletion tests/modeltests/validation/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""
XX. Validation
29. Validation
This is an experimental feature!
Each model instance has a validate() method that returns a dictionary of
validation errors in the instance's fields. This method has a side effect
Expand Down

0 comments on commit a846155

Please sign in to comment.