Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use quick and dirty fix instead of skipIf

  • Loading branch information...
commit 103893fa0c79c24105f508fc21d6e329d9fed333 1 parent 19f650f
@graingert authored
View
16 django_browserid/tests/__init__.py
@@ -4,7 +4,6 @@
from django.utils.functional import wraps
from mock import patch
-from nose.plugins.skip import SkipTest
def fake_create_user(email):
@@ -88,18 +87,3 @@ def inner(*args, **kwargs):
with self:
return func(*args, **kwargs)
return inner
-
-
-def skip_if(condition):
- """Skips tests if condition is True.
- """
- def skipped_wrapper(func):
- @wraps(func)
- def wrapped(*args, **kwargs):
- if condition:
- def skip_function(*args, **kwargs):
- raise SkipTest()
- return skip_function
- return func(*args, **kwargs)
- return wrapped
- return skipped_wrapper
View
60 django_browserid/tests/test_auth.py
@@ -8,7 +8,7 @@
from mock import ANY, patch
from django_browserid.auth import BrowserIDBackend, default_username_algo, verify
-from django_browserid.tests import mock_browserid, skip_if
+from django_browserid.tests import mock_browserid
try:
from django.contrib.auth import get_user_model
@@ -99,34 +99,34 @@ def test_verify_called_with_browserid_extra(self, user_verify):
user_verify.assert_called_with('asdf', 'asdf', extra_params=dic)
+if get_user_model:
# Only run custom user model tests if we're using a version of Django that
# supports it.
-@skip_if(not get_user_model) # 'Not supported in Django < 1.5'
-@patch.object(settings, 'AUTH_USER_MODEL', 'tests.CustomUser')
-class CustomUserModelTests(TestCase):
- def _auth(self, backend=None, verified_email=None):
- if backend is None:
- backend = BrowserIDBackend()
-
- with mock_browserid(verified_email):
- return backend.authenticate(assertion='asdf', audience='asdf')
-
- def test_existing_user(self):
- """If a custom user exists with the given email, return them."""
- user = CustomUser.objects.create(email='a@test.com')
- authed_user = self._auth(verified_email='a@test.com')
- self.assertEqual(user, authed_user)
-
- @patch.object(settings, 'BROWSERID_CREATE_USER', True)
- def test_create_new_user(self):
- """
- If a custom user does not exist with the given email, create a new
- user and return them.
- """
- class CustomUserBrowserIDBackend(BrowserIDBackend):
- def create_user(self, email):
- return CustomUser.objects.create(email=email)
- user = self._auth(backend=CustomUserBrowserIDBackend(),
- verified_email='b@test.com')
- self.assertTrue(isinstance(user, CustomUser))
- self.assertEqual(user.email, 'b@test.com')
+ @patch.object(settings, 'AUTH_USER_MODEL', 'tests.CustomUser')
+ class CustomUserModelTests(TestCase):
+ def _auth(self, backend=None, verified_email=None):
+ if backend is None:
+ backend = BrowserIDBackend()
+
+ with mock_browserid(verified_email):
+ return backend.authenticate(assertion='asdf', audience='asdf')
+
+ def test_existing_user(self):
+ """If a custom user exists with the given email, return them."""
+ user = CustomUser.objects.create(email='a@test.com')
+ authed_user = self._auth(verified_email='a@test.com')
+ self.assertEqual(user, authed_user)
+
+ @patch.object(settings, 'BROWSERID_CREATE_USER', True)
+ def test_create_new_user(self):
+ """
+ If a custom user does not exist with the given email, create a new
+ user and return them.
+ """
+ class CustomUserBrowserIDBackend(BrowserIDBackend):
+ def create_user(self, email):
+ return CustomUser.objects.create(email=email)
+ user = self._auth(backend=CustomUserBrowserIDBackend(),
+ verified_email='b@test.com')
+ self.assertTrue(isinstance(user, CustomUser))
+ self.assertEqual(user.email, 'b@test.com')
Please sign in to comment.
Something went wrong with that request. Please try again.