Index: string_lookup/models.py
===================================================================
--- string_lookup/models.py	(revision 3316)
+++ string_lookup/models.py	(working copy)
@@ -34,7 +34,7 @@
     def __str__(self):
         return "Base %s" % self.name
 
-API_TESTS = """
+__test__ = {'API_TESTS':"""
 # Regression test for #1661 and #1662: Check that string form referencing of models works, 
 # both as pre and post reference, on all RelatedField types.
 
@@ -66,4 +66,4 @@
 
 >>> child1.parent
 <Base: Base Base1>
-"""
+"""}
Index: markup/__init__.py
===================================================================
Index: markup/tests.py
===================================================================
--- markup/tests.py	(revision 0)
+++ markup/tests.py	(working copy)
@@ -1,68 +1,71 @@
 # Quick tests for the markup templatetags (django.contrib.markup)
 
 from django.template import Template, Context, add_to_builtins
-
+import unittest
 add_to_builtins('django.contrib.markup.templatetags.markup')
 
-# find out if markup modules are installed and tailor the test appropriately
-try:
-    import textile
-except ImportError:
-    textile = None
+class Templates(unittest.TestCase):
+    def test_textile(self):
+        try:
+            import textile
+        except ImportError:
+            textile = None
 
-try:
-    import markdown
-except ImportError:
-    markdown = None
+        ### test textile
+        
+        textile_content = """Paragraph 1
+        
+        Paragraph 2 with "quotes" and @code@"""
+        
+        t = Template("{{ textile_content|textile }}")
+        rendered = t.render(Context(locals())).strip()
+        if textile:
+            assert rendered == """<p>Paragraph 1</p>
+        
+        <p>Paragraph 2 with &#8220;quotes&#8221; and <code>code</code></p>"""
+        else:
+            assert rendered == textile_content
 
-try:
-    import docutils
-except ImportError:
-    docutils = None
+    def test_markdown(self):
+        try:
+            import markdown
+        except ImportError:
+            markdown = None
+        
+        ### test markdown
+        
+        markdown_content = """Paragraph 1
+        
+        ## An h2"""
+        
+        t = Template("{{ markdown_content|markdown }}")
+        rendered = t.render(Context(locals())).strip()
+        if markdown:
+            assert rendered == """<p>Paragraph 1</p><h2>An h2</h2>"""
+        else:
+            assert rendered == markdown_content
 
-# simple examples 'cause this isn't actually testing the markup, just
-# that the filters work as advertised
-
-### test textile
-
-textile_content = """Paragraph 1
-
-Paragraph 2 with "quotes" and @code@"""
-
-t = Template("{{ textile_content|textile }}")
-rendered = t.render(Context(locals())).strip()
-if textile:
-    assert rendered == """<p>Paragraph 1</p>
-
-<p>Paragraph 2 with &#8220;quotes&#8221; and <code>code</code></p>"""
-else:
-    assert rendered == textile_content
-
-### test markdown
-
-markdown_content = """Paragraph 1
-
-## An h2"""
-
-t = Template("{{ markdown_content|markdown }}")
-rendered = t.render(Context(locals())).strip()
-if markdown:
-    assert rendered == """<p>Paragraph 1</p><h2>An h2</h2>"""
-else:
-    assert rendered == markdown_content
-
-### test rest
-
-rest_content = """Paragraph 1
-
-Paragraph 2 with a link_
-
-.. _link: http://www.example.com/"""
-
-t = Template("{{ rest_content|restructuredtext }}")
-rendered = t.render(Context(locals())).strip()
-if docutils:
-    assert rendered =="""<p>Paragraph 1</p>
-<p>Paragraph 2 with a <a class="reference" href="http://www.example.com/">link</a></p>"""
-else:
-    assert rendered == rest_content
+    def test_rest(self):
+        try:
+            import docutils
+        except ImportError:
+            docutils = None
+        
+        ### test rest
+        
+        rest_content = """Paragraph 1
+        
+        Paragraph 2 with a link_
+        
+        .. _link: http://www.example.com/"""
+        
+        t = Template("{{ rest_content|restructuredtext }}")
+        rendered = t.render(Context(locals())).strip()
+        if docutils:
+            assert rendered =="""<p>Paragraph 1</p>
+        <p>Paragraph 2 with a <a class="reference" href="http://www.example.com/">link</a></p>"""
+        else:
+            assert rendered == rest_content
+            
+if __name__ == '__main__':
+    unittest.main()
\ No newline at end of file
Index: markup/models.py
===================================================================
Index: many_to_one_regress/models.py
===================================================================
--- many_to_one_regress/models.py	(revision 3316)
+++ many_to_one_regress/models.py	(working copy)
@@ -10,4 +10,4 @@
 # created (the field names being lower-cased versions of their opposite
 # classes is important here).
 
-API_TESTS = ""
+__test__ = {'API_TESTS':""}
Index: initial_sql_regress/models.py
===================================================================
--- initial_sql_regress/models.py	(revision 3316)
+++ initial_sql_regress/models.py	(working copy)
@@ -7,7 +7,7 @@
 class Simple(models.Model):
     name = models.CharField(maxlength = 50)
 
-API_TESTS = ""
+__test__ = {'API_TESTS':""}
 
 # NOTE: The format of the included SQL file for this test suite is important.
 # It must end with a trailing newline in order to test the fix for #2161.
Index: cache/__init__.py
===================================================================
Index: cache/tests.py
===================================================================
--- cache/tests.py	(revision 0)
+++ cache/tests.py	(working copy)
@@ -2,7 +2,7 @@
 # Uses whatever cache backend is set in the test settings file.
 
 from django.core.cache import cache
-import time
+import time, unittest
 
 # functions/classes for complex data type tests        
 def f():
@@ -11,50 +11,61 @@
     def m(n):
         return 24
 
-# simple set/get
-cache.set("key", "value")
-assert cache.get("key") == "value"
+class Cache(unittest.TestCase):
+    def test_simple(self):
+        # simple set/get
+        cache.set("key", "value")
+        self.assertEqual(cache.get("key"), "value")
+        
+    def test_non_existent(self):
+        # get with non-existent keys
+        self.assertEqual(cache.get("does not exist"), None)
+        self.assertEqual(cache.get("does not exist", "bang!"), "bang!")
+        
+    def test_get_many(self):
+        # get_many
+        cache.set('a', 'a')
+        cache.set('b', 'b')
+        cache.set('c', 'c')
+        cache.set('d', 'd')
+        
+        self.assertEqual(cache.get_many(['a', 'c', 'd']), {'a' : 'a', 'c' : 'c', 'd' : 'd'})
+        self.assertEqual(cache.get_many(['a', 'b', 'e']), {'a' : 'a', 'b' : 'b'})
+        
+    def test_delete(self):
+        # delete
+        cache.set("key1", "spam")
+        cache.set("key2", "eggs")
+        self.assertEqual(cache.get("key1"), "spam")
+        cache.delete("key1")
+        self.assertEqual(cache.get("key1"), None)
+        self.assertEqual(cache.get("key2"), "eggs")
+        
+    def test_has_key(self):
+        # has_key
+        cache.set("hello", "goodbye")
+        self.assertEqual(cache.has_key("hello"), True)
+        self.assertEqual(cache.has_key("goodbye"), False)
+        
+    def test_data_types(self):
+        # test data types
+        stuff = {
+            'string'    : 'this is a string',
+            'int'       : 42,
+            'list'      : [1, 2, 3, 4],
+            'tuple'     : (1, 2, 3, 4),
+            'dict'      : {'A': 1, 'B' : 2},
+            'function'  : f,
+            'class'     : C,
+        }
+        for (key, value) in stuff.items():
+            cache.set(key, value)
+            self.assertEqual(cache.get(key), value)
+            
+        # expiration
+        cache.set('expire', 'very quickly', 1)
+        time.sleep(2)
+        self.assertEqual(cache.get("expire"), None)
 
-# get with non-existent keys
-assert cache.get("does not exist") is None
-assert cache.get("does not exist", "bang!") == "bang!"
-
-# get_many
-cache.set('a', 'a')
-cache.set('b', 'b')
-cache.set('c', 'c')
-cache.set('d', 'd')
-assert cache.get_many(['a', 'c', 'd']) == {'a' : 'a', 'c' : 'c', 'd' : 'd'}
-assert cache.get_many(['a', 'b', 'e']) == {'a' : 'a', 'b' : 'b'}
-
-# delete
-cache.set("key1", "spam")
-cache.set("key2", "eggs")
-assert cache.get("key1") == "spam"
-cache.delete("key1")
-assert cache.get("key1") is None
-assert cache.get("key2") == "eggs"
-
-# has_key
-cache.set("hello", "goodbye")
-assert cache.has_key("hello") == True
-assert cache.has_key("goodbye") == False
-
-# test data types
-stuff = {
-    'string'    : 'this is a string',
-    'int'       : 42,
-    'list'      : [1, 2, 3, 4],
-    'tuple'     : (1, 2, 3, 4),
-    'dict'      : {'A': 1, 'B' : 2},
-    'function'  : f,
-    'class'     : C,
-}
-for (key, value) in stuff.items():
-    cache.set(key, value)
-    assert cache.get(key) == value
-    
-# expiration
-cache.set('expire', 'very quickly', 1)
-time.sleep(2)
-assert cache.get("expire") == None
+if __name__ == '__main__':
+    unittest.main()
\ No newline at end of file
Index: cache/models.py
===================================================================
Index: httpwrappers/__init__.py
===================================================================
Index: httpwrappers/models.py
===================================================================
Index: db_typecasts/__init__.py
===================================================================
Index: db_typecasts/tests.py
===================================================================
--- db_typecasts/tests.py	(revision 0)
+++ db_typecasts/tests.py	(working copy)
@@ -1,7 +1,7 @@
 # Unit tests for typecast functions in django.db.backends.util
 
 from django.db.backends import util as typecasts
-import datetime
+import datetime, unittest
 
 TEST_CASES = {
     'typecast_date': (
@@ -45,7 +45,12 @@
     ),
 }
 
-for k, v in TEST_CASES.items():
-    for inpt, expected in v:
-        got = getattr(typecasts, k)(inpt)
-        assert got == expected, "In %s: %r doesn't match %r. Got %r instead." % (k, inpt, expected, got)
+class DBTypeCasts(unittest.TestCase):
+    def test_typeCasts(self):
+        for k, v in TEST_CASES.items():
+            for inpt, expected in v:
+                got = getattr(typecasts, k)(inpt)
+                self.assertEqual(got, expected, "In %s: %r doesn't match %r. Got %r instead." % (k, inpt, expected, got))
+
+if __name__ == '__main__':
+    unittest.main()
\ No newline at end of file
Index: db_typecasts/models.py
===================================================================
Index: dateformat/__init__.py
===================================================================
Index: dateformat/tests.py
===================================================================
--- dateformat/tests.py	(revision 0)
+++ dateformat/tests.py	(working copy)
@@ -73,8 +73,13 @@
 os.environ['TZ'] = 'Europe/Copenhagen'
 translation.activate('en-us')
 
-time.tzset()
+#time.tzset()
 
 my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
 summertime = datetime.datetime(2005, 10, 30, 1, 00)
 wintertime = datetime.datetime(2005, 10, 30, 4, 00)
+
+
+if __name__ == '__main__':
+    import doctest
+    doctest.testmod()
Index: dateformat/models.py
===================================================================
Index: defaultfilters/__init__.py
===================================================================
Index: defaultfilters/models.py
===================================================================
Index: one_to_one_regress/models.py
===================================================================
--- one_to_one_regress/models.py	(revision 3316)
+++ one_to_one_regress/models.py	(working copy)
@@ -22,7 +22,7 @@
     def __str__(self):
         return "Favorites for %s" % self.name
 
-API_TESTS = """
+__test__ = {'API_TESTS':"""
 # Regression test for #1064 and #1506: Check that we create models via the m2m
 # relation if the remote model has a OneToOneField.
 >>> p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
@@ -34,4 +34,4 @@
 >>> f.restaurants = [r]
 >>> f.restaurants.all()
 [<Restaurant: Demon Dogs the restaurant>]
-"""
+"""}
Index: templates/__init__.py
===================================================================
Index: templates/tests.py
===================================================================
--- templates/tests.py	(revision 0)
+++ templates/tests.py	(working copy)
@@ -6,7 +6,7 @@
 from django.utils.translation import activate, deactivate, install
 from django.utils.tzinfo import LocalTimezone
 from datetime import datetime, timedelta
-import traceback
+import unittest
 
 #################################
 # Custom template tag for tests #
@@ -568,58 +568,45 @@
     except KeyError:
         raise template.TemplateDoesNotExist, template_name
 
-def run_tests(verbosity=0, standalone=False):
-    # Register our custom template loader.
-    old_template_loaders = loader.template_source_loaders
-    loader.template_source_loaders = [test_template_loader]
-
-    failed_tests = []
-    tests = TEMPLATE_TESTS.items()
-    tests.sort()
-
-    # Turn TEMPLATE_DEBUG off, because tests assume that.
-    old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
-    # Set TEMPLATE_STRING_IF_INVALID to a known string 
-    old_invalid, settings.TEMPLATE_STRING_IF_INVALID = settings.TEMPLATE_STRING_IF_INVALID, 'INVALID'
+class Templates(unittest.TestCase):
+    def test_templates(self):
+        # Register our custom template loader.
+        old_template_loaders = loader.template_source_loaders
+        loader.template_source_loaders = [test_template_loader]
     
-    for name, vals in tests:
-        install()
-        if 'LANGUAGE_CODE' in vals[1]:
-            activate(vals[1]['LANGUAGE_CODE'])
-        else:
-            activate('en-us')
-        try:
-            output = loader.get_template(name).render(template.Context(vals[1]))
-        except Exception, e:
-            if e.__class__ == vals[2]:
-                if verbosity:
-                    print "Template test: %s -- Passed" % name
+        failures = []
+        tests = TEMPLATE_TESTS.items()
+        tests.sort()
+    
+        # Turn TEMPLATE_DEBUG off, because tests assume that.
+        old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
+        # Set TEMPLATE_STRING_IF_INVALID to a known string 
+        old_invalid, settings.TEMPLATE_STRING_IF_INVALID = settings.TEMPLATE_STRING_IF_INVALID, 'INVALID'
+        
+        for name, vals in tests:
+            install()
+            if 'LANGUAGE_CODE' in vals[1]:
+                activate(vals[1]['LANGUAGE_CODE'])
             else:
-                if verbosity:
-                    traceback.print_exc()
-                    print "Template test: %s -- FAILED. Got %s, exception: %s" % (name, e.__class__, e)
-                failed_tests.append(name)
-            continue
-        if 'LANGUAGE_CODE' in vals[1]:
-            deactivate()
-        if output == vals[2]:
-            if verbosity:
-                print "Template test: %s -- Passed" % name
-        else:
-            if verbosity:
-                print "Template test: %s -- FAILED. Expected %r, got %r" % (name, vals[2], output)
-            failed_tests.append(name)
-    loader.template_source_loaders = old_template_loaders
-    deactivate()
-    settings.TEMPLATE_DEBUG = old_td
-    settings.TEMPLATE_STRING_IF_INVALID = old_invalid
-
-    if failed_tests and not standalone:
-        msg = "Template tests %s failed." % failed_tests
-        if not verbosity:
-            msg += "  Re-run tests with -v1 to see actual failures"
-        raise Exception, msg
-
-if __name__ == "__main__":
+                activate('en-us')
+            try:
+                output = loader.get_template(name).render(template.Context(vals[1]))
+            except Exception, e:                
+                if e.__class__ != vals[2]:
+                    failures.append("Template test: %s -- FAILED. Got %s, exception: %s" % (name, e.__class__, e))
+                continue
+                               
+            if 'LANGUAGE_CODE' in vals[1]:
+                deactivate()
+            if output != vals[2]:
+                failures.append("Template test: %s -- FAILED. Expected %r, got %r" % (name, vals[2], output))
+        loader.template_source_loaders = old_template_loaders
+        deactivate()
+        settings.TEMPLATE_DEBUG = old_td
+        settings.TEMPLATE_STRING_IF_INVALID = old_invalid
+    
+        self.assertEqual(failures,[])
+        
+if __name__ == '__main__':
     settings.configure()
-    run_tests(1, True)
+    unittest.main()
Index: templates/models.py
===================================================================
