summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/modeltests/custom_methods/models.py21
-rw-r--r--tests/modeltests/custom_methods/tests.py26
2 files changed, 26 insertions, 21 deletions
diff --git a/tests/modeltests/custom_methods/models.py b/tests/modeltests/custom_methods/models.py
index d420871373..f69a12694f 100644
--- a/tests/modeltests/custom_methods/models.py
+++ b/tests/modeltests/custom_methods/models.py
@@ -36,24 +36,3 @@ class Article(models.Model):
# The asterisk in "(*row)" tells Python to expand the list into
# positional arguments to Article().
return [self.__class__(*row) for row in cursor.fetchall()]
-
-__test__ = {'API_TESTS':"""
-# Create a couple of Articles.
->>> from datetime import date
->>> a = Article(id=None, headline='Area man programs in Python', pub_date=date(2005, 7, 27))
->>> a.save()
->>> b = Article(id=None, headline='Beatles reunite', pub_date=date(2005, 7, 27))
->>> b.save()
-
-# Test the custom methods.
->>> a.was_published_today()
-False
->>> 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>]
-"""}
diff --git a/tests/modeltests/custom_methods/tests.py b/tests/modeltests/custom_methods/tests.py
new file mode 100644
index 0000000000..4a344429a7
--- /dev/null
+++ b/tests/modeltests/custom_methods/tests.py
@@ -0,0 +1,26 @@
+from datetime import date
+
+from django.test import TestCase
+
+from models import Article
+
+class CustomMethodsTestCase(TestCase):
+ def test_custom_methods(self):
+ # Create a couple of Articles.
+ a = Article(id=None, headline='Area man programs in Python', pub_date=date(2005, 7, 27))
+ a.save()
+ b = Article(id=None, headline='Beatles reunite', pub_date=date(2005, 7, 27))
+ b.save()
+
+ # Test the custom methods.
+ self.assertFalse(a.was_published_today())
+
+ self.assertQuerysetEqual(a.articles_from_same_day_1(),
+ ['<Article: Beatles reunite>'])
+ self.assertQuerysetEqual(a.articles_from_same_day_2(),
+ ['<Article: Beatles reunite>'])
+ self.assertQuerysetEqual(b.articles_from_same_day_1(),
+ ['<Article: Area man programs in Python>'])
+ self.assertQuerysetEqual(b.articles_from_same_day_2(),
+ ['<Article: Area man programs in Python>'])
+