Index: django/contrib/auth/tests/__init__.py
===================================================================
--- django/contrib/auth/tests/__init__.py	(revision 13984)
+++ django/contrib/auth/tests/__init__.py	(working copy)
@@ -1,5 +1,5 @@
 from django.contrib.auth.tests.auth_backends import BackendTest, RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest
-from django.contrib.auth.tests.basic import BASIC_TESTS
+from django.contrib.auth.tests.basic import BasicTestCase
 from django.contrib.auth.tests.decorators import LoginRequiredTestCase
 from django.contrib.auth.tests.forms import UserCreationFormTest, AuthenticationFormTest, SetPasswordFormTest, PasswordChangeFormTest, UserChangeFormTest, PasswordResetFormTest
 from django.contrib.auth.tests.remote_user \
@@ -12,6 +12,5 @@
 # The password for the fixture data users is 'password'
 
 __test__ = {
-    'BASIC_TESTS': BASIC_TESTS,
     'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS,
 }
Index: django/contrib/auth/tests/basic.py
===================================================================
--- django/contrib/auth/tests/basic.py	(revision 13984)
+++ django/contrib/auth/tests/basic.py	(working copy)
@@ -1,77 +1,59 @@
+from django.test import TestCase
+from django.contrib.auth.models import User, AnonymousUser
+from django.core.management import call_command
 
-BASIC_TESTS = """
->>> from django.contrib.auth.models import User, AnonymousUser
->>> u = User.objects.create_user('testuser', 'test@example.com', 'testpw')
->>> u.has_usable_password()
-True
->>> u.check_password('bad')
-False
->>> u.check_password('testpw')
-True
->>> u.set_unusable_password()
->>> u.save()
->>> u.check_password('testpw')
-False
->>> u.has_usable_password()
-False
->>> u2 = User.objects.create_user('testuser2', 'test2@example.com')
->>> u2.has_usable_password()
-False
+class BasicTestCase(TestCase):
+    """
+    Basic test case class for all basic test cases.
+    """
 
->>> u.is_authenticated()
-True
->>> u.is_staff
-False
->>> u.is_active
-True
->>> u.is_superuser
-False
+    def setUp(self):
+        pass
+    
+    def tearDown(self):
+        pass
 
->>> a = AnonymousUser()
->>> a.is_authenticated()
-False
->>> a.is_staff
-False
->>> a.is_active
-False
->>> a.is_superuser
-False
->>> a.groups.all()
-[]
->>> a.user_permissions.all()
-[]
+    def test_user(self):
+        u = User.objects.create_user('testuser', 'test@example.com', 'testpw')
+        self.assertTrue(u.has_usable_password())
+        self.assertFalse(u.check_password('bad'))
+        self.assertTrue(u.check_password('testpw'))
+        u.set_unusable_password()
+        u.save()
+        self.assertFalse(u.check_password('testpw'))
+        self.assertFalse(u.has_usable_password())
+        u.set_password(None)
+        self.assertFalse(u.has_usable_password())
+        self.assertTrue(u.is_authenticated())
+        self.assertFalse(u.is_staff)
+        self.assertTrue(u.is_active)
+        self.assertFalse(u.is_superuser)
+        
+        u2 = User.objects.create_user('testuser2', 'test2@example.com')
+        self.assertFalse(u.has_usable_password())
 
-# superuser tests.
->>> super = User.objects.create_superuser('super', 'super@example.com', 'super')
->>> super.is_superuser
-True
->>> super.is_active
-True
->>> super.is_staff
-True
+    def test_anonymous_user(self):
+        a = AnonymousUser()
+        self.assertFalse(a.is_authenticated())
+        self.assertFalse(a.is_staff)
+        self.assertFalse(a.is_active)
+        self.assertFalse(a.is_superuser)
+        self.assertEquals(a.groups.all().count(), 0)
+        self.assertEquals(a.user_permissions.all().count(), 0)
+        
+    def test_superuser(self):
+        super = User.objects.create_superuser('super', 'super@example.com', 'super')
+        self.assertTrue(super.is_superuser)
+        self.assertTrue(super.is_active)
+        self.assertTrue(super.is_staff)
 
-#
-# Tests for createsuperuser management command.
-# It's nearly impossible to test the interactive mode -- a command test helper
-# would be needed (and *awesome*) -- so just test the non-interactive mode.
-# This covers most of the important validation, but not all.
-#
->>> from django.core.management import call_command
+    def test_createsuperuser_management_command(self):
+        call_command("createsuperuser", interactive=False, username="joe", email="joe@somewhere.org")
+        u = User.objects.get(username="joe")
+        self.assertEquals(u.email, 'joe@somewhere.org')
+        self.assertEquals(u.password, '!')
+        call_command("createsuperuser", interactive=False, username="joe+admin@somewhere.org", email="joe@somewhere.org")
+        u = User.objects.get(username="joe+admin@somewhere.org")
+        self.assertEquals(u.email, 'joe@somewhere.org')
+        self.assertEquals(u.password, '!')
 
->>> call_command("createsuperuser", interactive=False, username="joe", email="joe@somewhere.org")
-Superuser created successfully.
-
->>> u = User.objects.get(username="joe")
->>> u.email
-u'joe@somewhere.org'
->>> u.password
-u'!'
->>> call_command("createsuperuser", interactive=False, username="joe+admin@somewhere.org", email="joe@somewhere.org")
-Superuser created successfully.
-
->>> u = User.objects.get(username="joe+admin@somewhere.org")
->>> u.email
-u'joe@somewhere.org'
->>> u.password
-u'!'
-"""
Index: django/contrib/auth/models.py
===================================================================
--- django/contrib/auth/models.py	(revision 13984)
+++ django/contrib/auth/models.py	(working copy)
@@ -122,10 +122,7 @@
                          is_active=True, is_superuser=False, last_login=now,
                          date_joined=now)
 
-        if password:
-            user.set_password(password)
-        else:
-            user.set_unusable_password()
+        user.set_password(password)
         user.save(using=self._db)
         return user
 
@@ -238,11 +235,14 @@
         return full_name.strip()
 
     def set_password(self, raw_password):
-        import random
-        algo = 'sha1'
-        salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
-        hsh = get_hexdigest(algo, salt, raw_password)
-        self.password = '%s$%s$%s' % (algo, salt, hsh)
+        if not raw_password:
+            self.set_unusable_password()
+        else:
+            import random
+            algo = 'sha1'
+            salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
+            hsh = get_hexdigest(algo, salt, raw_password)
+            self.password = '%s$%s$%s' % (algo, salt, hsh)
 
     def check_password(self, raw_password):
         """
@@ -265,7 +265,11 @@
         self.password = UNUSABLE_PASSWORD
 
     def has_usable_password(self):
-        return self.password != UNUSABLE_PASSWORD
+        if not self.password \
+            or self.password == UNUSABLE_PASSWORD:
+            return False
+        else:
+            return True
 
     def get_group_permissions(self, obj=None):
         """
