Skip to content

Commit

Permalink
Use assert_raises instead of the full nose.tools.assert_raises
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbaptista committed Jun 16, 2014
1 parent 1245ff2 commit 45c1d4e
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions ckan/new_tests/logic/action/test_update.py
Expand Up @@ -87,14 +87,14 @@ def test_user_update_with_id_that_does_not_exist(self):
user_dict = factories.User.attributes()
user_dict['id'] = "there's no user with this id"

nose.tools.assert_raises(logic.NotFound, helpers.call_action,
'user_update', **user_dict)
assert_raises(logic.NotFound, helpers.call_action,
'user_update', **user_dict)

def test_user_update_with_no_id(self):
user_dict = factories.User.attributes()
assert 'id' not in user_dict
nose.tools.assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **user_dict)
assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **user_dict)

## START-FOR-LOOP-EXAMPLE

Expand All @@ -105,9 +105,9 @@ def test_user_update_with_invalid_name(self):
'a' * 200, 'Hi!', 'i++%')
for name in invalid_names:
user['name'] = name
nose.tools.assert_raises(logic.ValidationError,
helpers.call_action, 'user_update',
**user)
assert_raises(logic.ValidationError,
helpers.call_action, 'user_update',
**user)

## END-FOR-LOOP-EXAMPLE

Expand All @@ -118,8 +118,8 @@ def test_user_update_to_name_that_already_exists(self):
# Try to update fred and change his user name to bob, which is already
# bob's user name
fred['name'] = bob['name']
nose.tools.assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **fred)
assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **fred)

def test_user_update_password(self):
'''Test that updating a user's password works successfully.'''
Expand All @@ -143,8 +143,8 @@ def test_user_update_with_short_password(self):
user = factories.User()

user['password'] = 'xxx' # This password is too short.
nose.tools.assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **user)
assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **user)

def test_user_update_with_empty_password(self):
'''If an empty password is passed to user_update, nothing should
Expand All @@ -169,17 +169,17 @@ def test_user_update_with_null_password(self):
user = factories.User()

user['password'] = None
nose.tools.assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **user)
assert_raises(logic.ValidationError, helpers.call_action,
'user_update', **user)

def test_user_update_with_invalid_password(self):
user = factories.User()

for password in (False, -1, 23, 30.7):
user['password'] = password
nose.tools.assert_raises(logic.ValidationError,
helpers.call_action, 'user_update',
**user)
assert_raises(logic.ValidationError,
helpers.call_action, 'user_update',
**user)

def test_user_update_without_email_address(self):
'''You have to pass an email address when you call user_update.
Expand All @@ -197,9 +197,9 @@ def test_user_update_without_email_address(self):
user = factories.User()
del user['email']

nose.tools.assert_raises(logic.ValidationError,
helpers.call_action, 'user_update',
**user)
assert_raises(logic.ValidationError,
helpers.call_action, 'user_update',
**user)

# TODO: Valid and invalid values for the rest of the user model's fields.

Expand Down

0 comments on commit 45c1d4e

Please sign in to comment.