From 142e59b462e71fe4a253c8a3d7856ab900f5c4b2 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 3 Jun 2006 22:14:04 +0000 Subject: Fixed #2077 -- Renamed 'repr' model tests to 'str' git-svn-id: http://code.djangoproject.com/svn/django/trunk@3072 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/repr/__init__.py | 0 tests/modeltests/repr/models.py | 31 ------------------------------- tests/modeltests/str/__init__.py | 0 tests/modeltests/str/models.py | 31 +++++++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 tests/modeltests/repr/__init__.py delete mode 100644 tests/modeltests/repr/models.py create mode 100644 tests/modeltests/str/__init__.py create mode 100644 tests/modeltests/str/models.py diff --git a/tests/modeltests/repr/__init__.py b/tests/modeltests/repr/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/modeltests/repr/models.py b/tests/modeltests/repr/models.py deleted file mode 100644 index 7e5b98c4a5..0000000000 --- a/tests/modeltests/repr/models.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -2. Adding __repr__() to models - -Although it's not a strict requirement, each model should have a ``__repr__()`` -method to return a "human-readable" representation of the object. Do this not -only for your own sanity when dealing with the interactive prompt, but also -because objects' representations are used throughout Django's -automatically-generated admin. -""" - -from django.db import models - -class Article(models.Model): - headline = models.CharField(maxlength=100) - pub_date = models.DateTimeField() - - def __repr__(self): - return self.headline - -API_TESTS = """ -# Create an Article. ->>> from datetime import datetime ->>> a = Article(headline='Area man programs in Python', pub_date=datetime(2005, 7, 28)) ->>> a.save() - ->>> repr(a) -'Area man programs in Python' - ->>> a -Area man programs in Python -""" diff --git a/tests/modeltests/str/__init__.py b/tests/modeltests/str/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/modeltests/str/models.py b/tests/modeltests/str/models.py new file mode 100644 index 0000000000..4e4228ac89 --- /dev/null +++ b/tests/modeltests/str/models.py @@ -0,0 +1,31 @@ +""" +2. Adding __str__() to models + +Although it's not a strict requirement, each model should have a ``__str__()`` +method to return a "human-readable" representation of the object. Do this not +only for your own sanity when dealing with the interactive prompt, but also +because objects' representations are used throughout Django's +automatically-generated admin. +""" + +from django.db import models + +class Article(models.Model): + headline = models.CharField(maxlength=100) + pub_date = models.DateTimeField() + + def __str__(self): + return self.headline + +API_TESTS = """ +# Create an Article. +>>> from datetime import datetime +>>> a = Article(headline='Area man programs in Python', pub_date=datetime(2005, 7, 28)) +>>> a.save() + +>>> str(a) +'Area man programs in Python' + +>>> a + +""" -- cgit v1.3