Permalink
Browse files

Refs #2333 - Modified runtests script to use new testing framework. M…

…igrated existing tests to use Django testing framework. All the 'othertests' have been migrated into 'regressiontests', and converted into doctests/unittests, as appropriate.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3661 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 77ab11b commit 97b9ad73b4889ffebb3da2239b472bbfd1600177 @freakboy3742 freakboy3742 committed Aug 27, 2006
Showing with 949 additions and 3,791 deletions.
  1. +0 −2,665 tests/doctest.py
  2. +5 −6 tests/modeltests/basic/models.py
  3. +2 −2 tests/modeltests/choices/models.py
  4. +2 −2 tests/modeltests/custom_columns/models.py
  5. +2 −2 tests/modeltests/custom_managers/models.py
  6. +2 −2 tests/modeltests/custom_methods/models.py
  7. +2 −2 tests/modeltests/custom_pk/models.py
  8. +2 −2 tests/modeltests/empty/models.py
  9. +2 −2 tests/modeltests/field_defaults/models.py
  10. +2 −2 tests/modeltests/generic_relations/models.py
  11. +2 −2 tests/modeltests/get_latest/models.py
  12. +2 −2 tests/modeltests/get_or_create/models.py
  13. +1 −1 tests/modeltests/invalid_models/models.py
  14. +2 −2 tests/modeltests/lookup/models.py
  15. +2 −2 tests/modeltests/m2m_and_m2o/models.py
  16. +2 −2 tests/modeltests/m2m_intermediary/models.py
  17. +2 −2 tests/modeltests/m2m_multiple/models.py
  18. +2 −2 tests/modeltests/m2m_recursive/models.py
  19. +2 −2 tests/modeltests/m2o_recursive/models.py
  20. +2 −2 tests/modeltests/m2o_recursive2/models.py
  21. +2 −2 tests/modeltests/manipulators/models.py
  22. +2 −2 tests/modeltests/many_to_many/models.py
  23. +2 −2 tests/modeltests/many_to_one/models.py
  24. +2 −2 tests/modeltests/many_to_one_null/models.py
  25. +2 −2 tests/modeltests/model_inheritance/models.py
  26. +2 −2 tests/modeltests/mutually_referential/models.py
  27. +2 −2 tests/modeltests/one_to_one/models.py
  28. +2 −2 tests/modeltests/or_lookups/models.py
  29. +2 −2 tests/modeltests/ordering/models.py
  30. +2 −2 tests/modeltests/pagination/models.py
  31. +2 −2 tests/modeltests/properties/models.py
  32. +2 −2 tests/modeltests/reserved_names/models.py
  33. +2 −2 tests/modeltests/reverse_lookup/models.py
  34. +2 −2 tests/modeltests/save_delete_hooks/models.py
  35. +2 −2 tests/modeltests/serializers/models.py
  36. +2 −2 tests/modeltests/str/models.py
  37. +3 −3 tests/modeltests/transactions/models.py
  38. +2 −2 tests/modeltests/validation/models.py
  39. +0 −60 tests/othertests/cache.py
  40. +0 −70 tests/othertests/markup.py
  41. +0 −634 tests/othertests/templates.py
  42. 0 tests/{othertests → regressiontests/cache}/__init__.py
  43. 0 tests/regressiontests/cache/models.py
  44. +71 −0 tests/regressiontests/cache/tests.py
  45. 0 tests/regressiontests/dateformat/__init__.py
  46. 0 tests/regressiontests/dateformat/models.py
  47. 0 tests/{othertests/dateformat.py → regressiontests/dateformat/tests.py}
  48. 0 tests/regressiontests/db_typecasts/__init__.py
  49. 0 tests/regressiontests/db_typecasts/models.py
  50. +10 −5 tests/{othertests/db_typecasts.py → regressiontests/db_typecasts/tests.py}
  51. 0 tests/regressiontests/defaultfilters/__init__.py
  52. 0 tests/regressiontests/defaultfilters/models.py
  53. 0 tests/{othertests/defaultfilters.py → regressiontests/defaultfilters/tests.py}
  54. 0 tests/regressiontests/httpwrappers/__init__.py
  55. 0 tests/regressiontests/httpwrappers/models.py
  56. 0 tests/{othertests/httpwrappers.py → regressiontests/httpwrappers/tests.py}
  57. +1 −1 tests/regressiontests/initial_sql_regress/models.py
  58. +1 −1 tests/regressiontests/many_to_one_regress/models.py
  59. 0 tests/regressiontests/markup/__init__.py
  60. 0 tests/regressiontests/markup/models.py
  61. +69 −0 tests/regressiontests/markup/tests.py
  62. +2 −2 tests/regressiontests/one_to_one_regress/models.py
  63. +2 −2 tests/regressiontests/string_lookup/models.py
  64. 0 tests/regressiontests/templates/__init__.py
  65. 0 tests/regressiontests/templates/models.py
  66. +621 −0 tests/regressiontests/templates/tests.py
  67. 0 tests/regressiontests/urlpatterns_reverse/__init__.py
  68. 0 tests/regressiontests/urlpatterns_reverse/models.py
  69. +10 −18 tests/{othertests/urlpatterns_reverse.py → regressiontests/urlpatterns_reverse/tests.py}
  70. +85 −255 tests/runtests.py
View
@@ -13,8 +13,7 @@ class Article(models.Model):
def __str__(self):
return self.headline
-API_TESTS = """
-
+__test__ = {'API_TESTS': """
# No articles are in the system yet.
>>> Article.objects.all()
[]
@@ -314,14 +313,14 @@ def __str__(self):
>>> Article.objects.all()
[<Article: Article 6>, <Article: Default headline>, <Article: Article 7>, <Article: Updated article 8>]
-"""
+"""}
from django.conf import settings
building_docs = getattr(settings, 'BUILDING_DOCS', False)
if building_docs or settings.DATABASE_ENGINE == 'postgresql':
- API_TESTS += """
+ __test__['API_TESTS'] += """
# In PostgreSQL, microsecond-level precision is available.
>>> a9 = Article(headline='Article 9', pub_date=datetime(2005, 7, 31, 12, 30, 45, 180))
>>> a9.save()
@@ -330,7 +329,7 @@ def __str__(self):
"""
if building_docs or settings.DATABASE_ENGINE == 'mysql':
- API_TESTS += """
+ __test__['API_TESTS'] += """
# In MySQL, microsecond-level precision isn't available. You'll lose
# microsecond-level precision once the data is saved.
>>> a9 = Article(headline='Article 9', pub_date=datetime(2005, 7, 31, 12, 30, 45, 180))
@@ -339,7 +338,7 @@ def __str__(self):
datetime.datetime(2005, 7, 31, 12, 30, 45)
"""
-API_TESTS += """
+__test__['API_TESTS'] += """
# You can manually specify the primary key when creating a new object.
>>> a101 = Article(id=101, headline='Article 101', pub_date=datetime(2005, 7, 31, 12, 30, 45))
@@ -23,7 +23,7 @@ class Person(models.Model):
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> a = Person(name='Adrian', gender='M')
>>> a.save()
>>> s = Person(name='Sara', gender='F')
@@ -36,4 +36,4 @@ def __str__(self):
'Male'
>>> s.get_gender_display()
'Female'
-"""
+"""}
@@ -15,7 +15,7 @@ class Person(models.Model):
def __str__(self):
return '%s %s' % (self.first_name, self.last_name)
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create a Person.
>>> p = Person(first_name='John', last_name='Smith')
>>> p.save()
@@ -50,4 +50,4 @@ def __str__(self):
Traceback (most recent call last):
...
AttributeError: 'Person' object has no attribute 'last'
-"""
+"""}
@@ -58,7 +58,7 @@ class Car(models.Model):
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> p1 = Person(first_name='Bugs', last_name='Bunny', fun=True)
>>> p1.save()
>>> p2 = Person(first_name='Droopy', last_name='Dog', fun=False)
@@ -104,4 +104,4 @@ def __str__(self):
# to the first manager defined in the class. In this case, it's "cars".
>>> Car._default_manager.order_by('name')
[<Car: Corvette>, <Car: Neon>]
-"""
+"""}
@@ -36,7 +36,7 @@ def articles_from_same_day_2(self):
# positional arguments to Article().
return [self.__class__(*row) for row in cursor.fetchall()]
-API_TESTS = """
+__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))
@@ -55,4 +55,4 @@ def articles_from_same_day_2(self):
[<Article: Area man programs in Python>]
>>> b.articles_from_same_day_2()
[<Article: Area man programs in Python>]
-"""
+"""}
@@ -27,7 +27,7 @@ class Meta:
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> dan = Employee(employee_code='ABC123', first_name='Dan', last_name='Jones')
>>> dan.save()
>>> Employee.objects.all()
@@ -88,4 +88,4 @@ def __str__(self):
>>> Business.objects.filter(employees__first_name__startswith='Fran')
[<Business: Sears>]
-"""
+"""}
@@ -10,7 +10,7 @@
class Empty(models.Model):
pass
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> m = Empty()
>>> m.id
>>> m.save()
@@ -23,4 +23,4 @@ class Empty(models.Model):
>>> existing = Empty(m.id)
>>> existing.save()
-"""
+"""}
@@ -19,7 +19,7 @@ class Article(models.Model):
def __str__(self):
return self.headline
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> from datetime import datetime
# No articles are in the system yet.
@@ -48,4 +48,4 @@ def __str__(self):
>>> d = now - a.pub_date
>>> d.seconds < 5
True
-"""
+"""}
@@ -53,7 +53,7 @@ class Mineral(models.Model):
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create the world in 7 lines of code...
>>> lion = Animal(common_name="Lion", latin_name="Panthera leo")
>>> platypus = Animal(common_name="Platypus", latin_name="Ornithorhynchus anatinus")
@@ -105,4 +105,4 @@ def __str__(self):
[<TaggedItem: shiny>]
>>> TaggedItem.objects.filter(content_type__pk=ctype.id, object_id=quartz.id)
[<TaggedItem: clearish>]
-"""
+"""}
@@ -29,7 +29,7 @@ class Person(models.Model):
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Because no Articles exist yet, get_latest() raises ArticleDoesNotExist.
>>> Article.objects.latest()
Traceback (most recent call last):
@@ -76,4 +76,4 @@ def __str__(self):
>>> Person.objects.latest('birthday')
<Person: Stephanie>
-"""
+"""}
@@ -15,7 +15,7 @@ class Person(models.Model):
def __str__(self):
return '%s %s' % (self.first_name, self.last_name)
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Acting as a divine being, create an Person.
>>> from datetime import date
>>> p = Person(first_name='John', last_name='Lennon', birthday=date(1940, 10, 9))
@@ -49,4 +49,4 @@ def __str__(self):
False
>>> Person.objects.count()
2
-"""
+"""}
@@ -78,7 +78,7 @@ class SelfClashM2M(models.Model):
-error_log = """invalid_models.fielderrors: "charfield": CharFields require a "maxlength" attribute.
+model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "maxlength" attribute.
invalid_models.fielderrors: "floatfield": FloatFields require a "decimal_places" attribute.
invalid_models.fielderrors: "floatfield": FloatFields require a "max_digits" attribute.
invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute.
@@ -15,7 +15,7 @@ class Meta:
def __str__(self):
return self.headline
-API_TESTS = r"""
+__test__ = {'API_TESTS':r"""
# Create a couple of Articles.
>>> from datetime import datetime
>>> a1 = Article(headline='Article 1', pub_date=datetime(2005, 7, 26))
@@ -191,4 +191,4 @@ def __str__(self):
>>> Article.objects.filter(headline__contains='\\')
[<Article: Article with \ backslash>]
-"""
+"""}
@@ -21,7 +21,7 @@ class Meta:
ordering = ('num',)
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> Issue.objects.all()
[]
>>> r = User(username='russell')
@@ -62,4 +62,4 @@ class Meta:
[<Issue: 1>, <Issue: 2>, <Issue: 3>]
>>> Issue.objects.filter(Q(client=r.id) | Q(cc__id__exact=r.id))
[<Issue: 1>, <Issue: 2>, <Issue: 3>]
-"""
+"""}
@@ -34,7 +34,7 @@ class Writer(models.Model):
def __str__(self):
return '%s (%s)' % (self.reporter, self.position)
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create a few Reporters.
>>> r1 = Reporter(first_name='John', last_name='Smith')
>>> r1.save()
@@ -65,4 +65,4 @@ def __str__(self):
<Article: This is a test>
>>> r1.writer_set.all()
[<Writer: John Smith (Main writer)>]
-"""
+"""}
@@ -28,7 +28,7 @@ class Meta:
def __str__(self):
return self.headline
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> from datetime import datetime
>>> c1 = Category(name='Sports')
@@ -76,4 +76,4 @@ def __str__(self):
[]
>>> c4.secondary_article_set.all()
[<Article: Area man steals>, <Article: Area man runs>]
-"""
+"""}
@@ -22,7 +22,7 @@ class Person(models.Model):
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> a = Person(name='Anne')
>>> a.save()
>>> b = Person(name='Bill')
@@ -189,4 +189,4 @@ def __str__(self):
>>> d.stalkers.all()
[<Person: Chuck>]
-"""
+"""}
@@ -19,7 +19,7 @@ class Category(models.Model):
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create a few Category objects.
>>> r = Category(id=None, name='Root category', parent=None)
>>> r.save()
@@ -37,4 +37,4 @@ def __str__(self):
[]
>>> c.parent
<Category: Root category>
-"""
+"""}
@@ -17,7 +17,7 @@ class Person(models.Model):
def __str__(self):
return self.full_name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create two Person objects -- the mom and dad in our family.
>>> dad = Person(full_name='John Smith Senior', mother=None, father=None)
>>> dad.save()
@@ -40,4 +40,4 @@ def __str__(self):
[]
>>> kid.fathers_child_set.all()
[]
-"""
+"""}
@@ -21,7 +21,7 @@ class Album(models.Model):
def __str__(self):
return self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
>>> from django.utils.datastructures import MultiValueDict
# Create a Musician object via the default AddManipulator.
@@ -88,4 +88,4 @@ def __str__(self):
<Album: Ultimate Ella>
>>> a2.release_date
datetime.date(2005, 2, 13)
-"""
+"""}
@@ -28,7 +28,7 @@ def __str__(self):
class Meta:
ordering = ('headline',)
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create a couple of Publications.
>>> p1 = Publication(id=None, title='The Python Journal')
>>> p1.save()
@@ -231,4 +231,4 @@ class Meta:
>>> p1.article_set.all()
[<Article: NASA uses Python>]
-"""
+"""}
@@ -25,7 +25,7 @@ def __str__(self):
class Meta:
ordering = ('headline',)
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create a few Reporters.
>>> r = Reporter(first_name='John', last_name='Smith', email='john@example.com')
>>> r.save()
@@ -263,4 +263,4 @@ class Meta:
>>> Article.objects.all()
[]
-"""
+"""}
@@ -23,7 +23,7 @@ class Meta:
def __str__(self):
return self.headline
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Create a Reporter.
>>> r = Reporter(name='John Smith')
>>> r.save()
@@ -121,4 +121,4 @@ def __str__(self):
>>> Article.objects.filter(reporter__isnull=True)
[<Article: First>, <Article: Fourth>]
-"""
+"""}
@@ -26,7 +26,7 @@ class ItalianRestaurant(Restaurant):
def __str__(self):
return "%s the italian restaurant" % self.name
-API_TESTS = """
+__test__ = {'API_TESTS':"""
# Make sure Restaurant has the right fields in the right order.
>>> [f.name for f in Restaurant._meta.fields]
['id', 'name', 'address', 'serves_hot_dogs', 'serves_pizza']
@@ -50,4 +50,4 @@ def __str__(self):
>>> ir.save()
-"""
+"""}
Oops, something went wrong. Retry.

0 comments on commit 97b9ad7

Please sign in to comment.