Skip to content

Commit

Permalink
[tests]: Fix assert_in and assert_not_in imports - they needs Python …
Browse files Browse the repository at this point in the history
…2.7, so have a fallback for Python 2.5 and 2.6.
  • Loading branch information
David Read committed Mar 8, 2012
1 parent 0efe8a7 commit 0632a8b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ckan/tests/__init__.py
Expand Up @@ -338,3 +338,11 @@ def skip_test(*args):

def clear_flash(res=None):
messages = _flash.pop_messages()

try:
from nose.tools import assert_in, assert_not_in
except ImportError:
def assert_in(a, b):
assert a in b, '%r was not in %r' % (a, b)
def assert_not_in(a, b):
assert a not in b, '%r was in %r' % (a, b)
12 changes: 12 additions & 0 deletions ckan/tests/functional/api/model/test_package.py
Expand Up @@ -245,6 +245,18 @@ def test_register_post_bad_request(self):
res = self.app.post(offset, params=postparams, status=self.STATUS_400_BAD_REQUEST,
extra_environ=self.extra_environ)

def test_register_post_bad_request_2(self):
test_params = {
'name':u'testpackage07_400',
'extras':[ # should not be a list in here
{u'key': u'value}
],
}
offset = self.offset('/rest/dataset')
postparams = '%s=1' % self.dumps(test_params)
res = self.app.post(offset, params=postparams, status=self.STATUS_400_BAD_REQUEST,
extra_environ=self.extra_environ)

def test_register_post_denied(self):
offset = self.offset('/rest/dataset')
postparams = '%s=1' % self.dumps(self.package_fixture_data)
Expand Down
2 changes: 1 addition & 1 deletion ckan/tests/lib/test_dictization.py
@@ -1,4 +1,4 @@
from nose.tools import assert_equal, assert_not_in, assert_in
from ckan.tests import assert_equal, assert_not_in, assert_in
from pprint import pprint, pformat
from difflib import unified_diff

Expand Down

0 comments on commit 0632a8b

Please sign in to comment.