Skip to content

Commit

Permalink
Change way to call nose's assert_raises, so it works on Python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbaptista authored and amercader committed Jun 19, 2014
1 parent c289662 commit 8c30404
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions ckan/new_tests/logic/auth/test_update.py
Expand Up @@ -35,11 +35,8 @@ def test_user_update_visitor_cannot_update_user(self):
'name': 'updated_user_name',
}

with nose.tools.assert_raises(logic.NotAuthorized) as cm:
helpers.call_auth('user_update', context=context, **params)

assert cm.exception.extra_msg == ('User 127.0.0.1 not authorized to '
'edit user fred_user_id')
nose.tools.assert_raises(logic.NotAuthorized, helpers.call_auth,
'user_update', context=context, **params)

## START-AFTER

Expand Down Expand Up @@ -73,11 +70,8 @@ def test_user_update_user_cannot_update_another_user(self):

# 3. Make assertions about the return value and/or side-effects.

with nose.tools.assert_raises(logic.NotAuthorized) as cm:
helpers.call_auth('user_update', context=context, **params)

assert cm.exception.extra_msg == ('User bob not authorized to edit '
'user fred_user_id')
nose.tools.assert_raises(logic.NotAuthorized, helpers.call_auth,
'user_update', context=context, **params)

# 4. Do nothing else!

Expand Down Expand Up @@ -132,9 +126,8 @@ def test_user_update_with_no_user_in_context(self):
'id': mock_user.id,
'name': 'updated_user_name',
}
with nose.tools.assert_raises(logic.NotAuthorized) as cm:
helpers.call_auth('user_update', context=context, **params)

assert cm.exception.extra_msg == 'Have to be logged in to edit user'
nose.tools.assert_raises(logic.NotAuthorized, helpers.call_auth,
'user_update', context=context, **params)

# TODO: Tests for user_update's reset_key behavior.

0 comments on commit 8c30404

Please sign in to comment.