Index: django/test/http.py
===================================================================
--- django/test/http.py	(revision 0)
+++ django/test/http.py	(revision 0)
@@ -0,0 +1,82 @@
+import unittest, thread, sys
+from django.core.servers.basehttp import WSGIServer, AdminMediaHandler, WSGIServerException, WSGIRequestHandler
+from django.core.handlers.wsgi import WSGIHandler
+from django.conf import settings
+from django.core.management import get_version, style
+
+ADDR = 'localhost'
+PORT = 8888
+TEST_SERVER_FAIL = 'Test server failed to start'
+
+class WSGIServerWrapper(WSGIServer):
+    """
+    Wrapper for WSGIServer.
+    
+    This is required for some added exception handling and to ignore an annoying unhandled
+    exception when calling server_close() after serve_forever() has been called in a thread.
+    """
+    def serve_forever(self):
+        try:
+            WSGIServer.serve_forever(self)
+        except WSGIServerException, e:
+            # Use helpful error messages instead of ugly tracebacks.
+            ERRORS = {
+                13: "You don't have permission to access that port.",
+                98: "That port is already in use.",
+                99: "That IP address can't be assigned-to.",
+            }
+            try:
+                error_text = ERRORS[e.args[0].args[0]]
+            except (AttributeError, KeyError):
+                error_text = str(e)
+            self.error = "Error: %s" % error_text
+        except:
+            # This is a hacky way of dealing with the error received when the exception is triggered
+            # from the server.server_close(). Because of this hack we must make sure the server came up
+            # after calling serve_forever()
+            pass
+
+              
+def create_test_server(addr, port):
+    """
+    Method to create and return the test server object (instance of WSGIServerWrapper)
+    """
+    print "\nDjango version %s, on %r:%r" % (get_version(), ADDR, PORT)
+    
+    import django
+    path = django.__path__[0] + '/contrib/admin/media'
+    handler = AdminMediaHandler(WSGIHandler(), media_dir=path)
+    server_address = (addr, port)
+    httpd = WSGIServerWrapper(server_address, WSGIRequestHandler)
+    httpd.set_app(handler)
+    
+    return httpd
+
+
+class HttpTestCase(unittest.TestCase):
+    """
+    HttpTestCase is intended to be used for live HTTP testing of your django applications
+    using the django test server.
+    """
+    
+    def setUp(self):
+        # Setup server for test run and assign it to self
+        self.server = create_test_server(ADDR, PORT)
+        self.server_thread_id = thread.start_new_thread(self.server.serve_forever, ())
+                
+        # Test that the server is up since we ignore any exceptions -- see above.
+        import socket
+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        try:
+            s.connect((ADDR, PORT))
+            s.close()
+        except:
+            if hasattr(self.server, 'error'):
+                sys.stderr.write(style(self.server.error) + '\n')
+            else:
+                raise TEST_SERVER_FAIL
+
+        
+    def tearDown(self):
+        #Kill the server
+        self.server.server_close()
\ No newline at end of file
Index: django/test/utils.py
===================================================================
--- django/test/utils.py	(revision 3896)
+++ django/test/utils.py	(working copy)
@@ -45,10 +45,12 @@
 def create_test_db(verbosity=1, autoclobber=False):
     if verbosity >= 1:
         print "Creating test database..."
-    # If we're using SQLite, it's more convenient to test against an
-    # in-memory database.
+    # Check if we're using sqlite
     if settings.DATABASE_ENGINE == "sqlite3":
-        TEST_DATABASE_NAME = ":memory:"
+        if settings.TEST_DATABASE_NAME:
+            TEST_DATABASE_NAME = settings.TEST_DATABASE_NAME
+        else:
+            TEST_DATABASE_NAME = TEST_DATABASE_PREFIX + settings.DATABASE_NAME
     else:
         if settings.TEST_DATABASE_NAME:
             TEST_DATABASE_NAME = settings.TEST_DATABASE_NAME
@@ -105,3 +107,9 @@
         time.sleep(1) # To avoid "database is being accessed by other users" errors.
         cursor.execute("DROP DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME))
         connection.close()
+    # If using an in memory sqlite database do not attempt to remove it
+    elif TEST_DATABASE_NAME != ":memory:":
+        from os import remove
+        remove(TEST_DATABASE_NAME)
+        
+            
