summaryrefslogtreecommitdiff
path: root/tests/modeltests/custom_methods
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-06-04 00:23:51 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-06-04 00:23:51 +0000
commita5b7c298164e3c1547988c734d6155c17f57b1d7 (patch)
treeea42bc0b63aaf2db9600fa2546b98807bdee4f90 /tests/modeltests/custom_methods
parent55e453a09c071cd34962d5b809121aa17241aaae (diff)
Changed all model unit tests to use __str__() instead of __repr__(). Also slightly changed related-object DoesNotExist exception message to use repr instead of str
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3075 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/custom_methods')
-rw-r--r--tests/modeltests/custom_methods/models.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/modeltests/custom_methods/models.py b/tests/modeltests/custom_methods/models.py
index 6cc3fe8548..e314d97264 100644
--- a/tests/modeltests/custom_methods/models.py
+++ b/tests/modeltests/custom_methods/models.py
@@ -11,16 +11,16 @@ class Article(models.Model):
headline = models.CharField(maxlength=100)
pub_date = models.DateField()
- def __repr__(self):
+ def __str__(self):
return self.headline
def was_published_today(self):
return self.pub_date == datetime.date.today()
- def get_articles_from_same_day_1(self):
+ def articles_from_same_day_1(self):
return Article.objects.filter(pub_date=self.pub_date).exclude(id=self.id)
- def get_articles_from_same_day_2(self):
+ def articles_from_same_day_2(self):
"""
Verbose version of get_articles_from_same_day_1, which does a custom
database query for the sake of demonstration.
@@ -47,12 +47,12 @@ API_TESTS = """
# Test the custom methods.
>>> a.was_published_today()
False
->>> a.get_articles_from_same_day_1()
-[Beatles reunite]
->>> a.get_articles_from_same_day_2()
-[Beatles reunite]
->>> b.get_articles_from_same_day_1()
-[Area man programs in Python]
->>> b.get_articles_from_same_day_2()
-[Area man programs in Python]
+>>> a.articles_from_same_day_1()
+[<Article: Beatles reunite>]
+>>> a.articles_from_same_day_2()
+[<Article: Beatles reunite>]
+>>> b.articles_from_same_day_1()
+[<Article: Area man programs in Python>]
+>>> b.articles_from_same_day_2()
+[<Article: Area man programs in Python>]
"""