Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fixing auth basic tests #392

Closed
wants to merge 1 commit into from

3 participants

Vinicius Ruan Cainelli Preston Holmes Jannis Leidel
Vinicius Ruan Cainelli

Testing method User.objects.create_user() without password param.

Preston Holmes
Collaborator

This was fixed in 8755fb1#diff-4

Preston Holmes ptone closed this
Vinicius Ruan Cainelli

Look this: 8755fb1#L4R31

It is creating an user at variable u2 and is testing the variable u again, so the variable u2 is not being used/tested.

Preston Holmes
Collaborator

Though I had linked to the wrong commit - you are correct - while the code was altered in the recent 3011 work, it still contained the logic flaw.

70a0de3#L17L36

I'll land a fix shortly - thanks for the keen eye and followup.

Preston Holmes ptone reopened this
Preston Holmes ptone closed this pull request from a commit
Preston Holmes ptone Fixed a small oversight in auth tests
Thanks to Vinicius Ruan Cainelli for the catch
closes #392
0136274
Preston Holmes ptone closed this in 0136274
Jannis Leidel
Owner

@ptone I'm pretty sure that doesn't fix #392. Please make sure to use Trac ticket IDs to reduce the number of wrong comments there (see https://code.djangoproject.com/ticket/392)

Mehmet Akyuz mehmetakyuz referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2012
  1. Vinicius Ruan Cainelli
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 8 deletions.
  1. +10 −8 django/contrib/auth/tests/basic.py
18 django/contrib/auth/tests/basic.py
View
@@ -1,5 +1,4 @@
import locale
-import traceback
from django.contrib.auth.management.commands import createsuperuser
from django.contrib.auth.models import User, AnonymousUser
@@ -34,7 +33,7 @@ def test_user(self):
# Check API-based user creation with no password
u2 = User.objects.create_user('testuser2', 'test2@example.com')
- self.assertFalse(u.has_usable_password())
+ self.assertFalse(u2.has_usable_password())
def test_user_no_email(self):
"Check that users can be created without an email"
@@ -69,7 +68,8 @@ def test_createsuperuser_management_command(self):
"Check the operation of the createsuperuser management command"
# We can use the management command to create a superuser
new_io = StringIO()
- call_command("createsuperuser",
+ call_command(
+ "createsuperuser",
interactive=False,
username="joe",
email="joe@somewhere.org",
@@ -85,7 +85,8 @@ def test_createsuperuser_management_command(self):
# We can supress output on the management command
new_io = StringIO()
- call_command("createsuperuser",
+ call_command(
+ "createsuperuser",
interactive=False,
username="joe2",
email="joe2@somewhere.org",
@@ -98,9 +99,9 @@ def test_createsuperuser_management_command(self):
self.assertEqual(u.email, 'joe2@somewhere.org')
self.assertFalse(u.has_usable_password())
-
new_io = StringIO()
- call_command("createsuperuser",
+ call_command(
+ "createsuperuser",
interactive=False,
username="joe+admin@somewhere.org",
email="joe@somewhere.org",
@@ -124,7 +125,8 @@ def test_createsuperuser_nolocale(self):
# Temporarily replace getpass to allow interactive code to be used
# non-interactively
- class mock_getpass: pass
+ class mock_getpass:
+ pass
mock_getpass.getpass = staticmethod(lambda p=None: "nopasswd")
createsuperuser.getpass = mock_getpass
@@ -132,7 +134,7 @@ class mock_getpass: pass
new_io = StringIO()
call_command("createsuperuser", interactive=True, username="nolocale@somewhere.org", email="nolocale@somewhere.org", stdout=new_io)
- except TypeError as e:
+ except TypeError:
self.fail("createsuperuser fails if the OS provides no information about the current locale")
finally:
Something went wrong with that request. Please try again.