Skip to content

Commit

Permalink
[#3126] remove assert_(not)_in from helpers
Browse files Browse the repository at this point in the history
- `assert_in` and `assert_not_in` were duplicated
  in `ckan/tests/legacy/__init__.py` and
  `ckan.tests.helpers` because they were not
  available in python2.6
- This commit removes the back porting from those
  files and just imports from nose.tools directly
  everywhere
  • Loading branch information
Knut Hühne committed Jun 17, 2016
1 parent 1efb47a commit f8bd2cd
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 50 deletions.
3 changes: 1 addition & 2 deletions ckan/tests/controllers/test_api.py
Expand Up @@ -7,10 +7,9 @@
import json

from routes import url_for
from nose.tools import assert_equal
from nose.tools import assert_equal, assert_in

import ckan.tests.helpers as helpers
from ckan.tests.helpers import assert_in
from ckan.tests import factories
from ckan import model

Expand Down
3 changes: 1 addition & 2 deletions ckan/tests/controllers/test_group.py
@@ -1,15 +1,14 @@
# encoding: utf-8

from bs4 import BeautifulSoup
from nose.tools import assert_equal, assert_true
from nose.tools import assert_equal, assert_true, assert_in

from routes import url_for

import ckan.tests.helpers as helpers
import ckan.model as model
from ckan.tests import factories

assert_in = helpers.assert_in
webtest_submit = helpers.webtest_submit
submit_and_follow = helpers.submit_and_follow

Expand Down
4 changes: 2 additions & 2 deletions ckan/tests/controllers/test_organization.py
@@ -1,12 +1,12 @@
# encoding: utf-8

from bs4 import BeautifulSoup
from nose.tools import assert_equal, assert_true
from nose.tools import assert_equal, assert_true, assert_in
from routes import url_for
from mock import patch

from ckan.tests import factories, helpers
from ckan.tests.helpers import webtest_submit, submit_and_follow, assert_in
from ckan.tests.helpers import webtest_submit, submit_and_follow


class TestOrganizationNew(helpers.FunctionalTestBase):
Expand Down
3 changes: 1 addition & 2 deletions ckan/tests/controllers/test_package.py
Expand Up @@ -6,6 +6,7 @@
assert_not_equal,
assert_raises,
assert_true,
assert_in
)

from mock import patch, MagicMock
Expand All @@ -17,10 +18,8 @@

import ckan.tests.helpers as helpers
import ckan.tests.factories as factories
from ckan.tests.helpers import assert_in


assert_in = helpers.assert_in
webtest_submit = helpers.webtest_submit
submit_and_follow = helpers.submit_and_follow

Expand Down
3 changes: 1 addition & 2 deletions ckan/tests/controllers/test_tags.py
Expand Up @@ -3,15 +3,14 @@
import math
import string

from nose.tools import assert_equal, assert_true, assert_false
from nose.tools import assert_equal, assert_true, assert_false, assert_in
from bs4 import BeautifulSoup

from routes import url_for

import ckan.tests.helpers as helpers
from ckan.tests import factories

assert_in = helpers.assert_in
webtest_submit = helpers.webtest_submit
submit_and_follow = helpers.submit_and_follow

Expand Down
12 changes: 1 addition & 11 deletions ckan/tests/helpers.py
Expand Up @@ -22,6 +22,7 @@
import webtest
from pylons import config
import nose.tools
from nose.tools import assert_in, assert_not_in
import mock

import ckan.lib.search as search
Expand All @@ -30,17 +31,6 @@
import ckan.logic as logic


try:
from nose.tools import assert_in, assert_not_in
except ImportError:
# Python 2.6 doesn't have these, so define them here
def assert_in(a, b, msg=None):
assert a in b, msg or '%r was not in %r' % (a, b)

def assert_not_in(a, b, msg=None):
assert a not in b, msg or '%r was in %r' % (a, b)


def reset_db():
'''Reset CKAN's database.
Expand Down
9 changes: 0 additions & 9 deletions ckan/tests/legacy/__init__.py
Expand Up @@ -355,15 +355,6 @@ def skip_test(*args):
def clear_flash(res=None):
messages = h._flash.pop_messages()

try:
from nose.tools import assert_in, assert_not_in
except ImportError:
def assert_in(a, b, msg=None):
assert a in b, msg or '%r was not in %r' % (a, b)
def assert_not_in(a, b, msg=None):
assert a not in b, msg or '%r was in %r' % (a, b)


class StatusCodes:
STATUS_200_OK = 200
STATUS_201_CREATED = 201
Expand Down
4 changes: 2 additions & 2 deletions ckan/tests/legacy/functional/api/test_api.py
Expand Up @@ -2,10 +2,10 @@

import json

from nose.tools import assert_in

from ckan.tests.legacy.functional.api.base import *

import ckan.tests.legacy
assert_in = ckan.tests.legacy.assert_in

class ApiTestCase(ApiTestCase, ControllerTestCase):

Expand Down
4 changes: 2 additions & 2 deletions ckan/tests/legacy/lib/test_dictization.py
@@ -1,10 +1,10 @@
# encoding: utf-8

from ckan.tests.legacy import assert_equal, assert_not_in, assert_in
from nose.tools import assert_equal, assert_not_in, assert_in
from pprint import pprint, pformat
from difflib import unified_diff
import ckan.lib.search as search

import ckan.lib.search as search
from ckan.lib.create_test_data import CreateTestData
from ckan import model
from ckan.lib.dictization import (table_dictize,
Expand Down
5 changes: 4 additions & 1 deletion ckan/tests/legacy/models/test_group.py
@@ -1,9 +1,12 @@
# encoding: utf-8

from ckan.tests.legacy import assert_equal, assert_in, assert_not_in, CreateTestData
from nose.tools import assert_in, assert_not_in, assert_equal

from ckan.tests.legacy import CreateTestData

import ckan.model as model


class TestGroup(object):

@classmethod
Expand Down
6 changes: 1 addition & 5 deletions ckan/tests/lib/search/test_index.py
Expand Up @@ -3,17 +3,13 @@
import datetime
import hashlib
import json
import nose.tools
import nose
from nose.tools import assert_equal, assert_in, assert_not_in

from pylons import config
import ckan.lib.search as search
import ckan.tests.helpers as helpers

assert_equal = nose.tools.assert_equal
assert_in = helpers.assert_in
assert_not_in = helpers.assert_not_in


class TestSearchIndex(object):

Expand Down
4 changes: 1 addition & 3 deletions ckan/tests/lib/test_mailer.py
@@ -1,6 +1,6 @@
# encoding: utf-8

from nose.tools import assert_equal, assert_raises
from nose.tools import assert_equal, assert_raises, assert_in
from pylons import config
from email.mime.text import MIMEText
from email.parser import Parser
Expand All @@ -16,8 +16,6 @@
import ckan.tests.helpers as helpers
import ckan.tests.factories as factories

assert_in = helpers.assert_in


class MailerBase(SmtpServerHarness):

Expand Down
3 changes: 1 addition & 2 deletions ckanext/example_igroupform/tests/test_controllers.py
@@ -1,14 +1,13 @@
# encoding: utf-8

from nose.tools import assert_equal
from nose.tools import assert_equal, assert_in
from routes import url_for

import ckan.plugins as plugins
import ckan.tests.helpers as helpers
import ckan.model as model
from ckan.tests import factories

assert_in = helpers.assert_in
webtest_submit = helpers.webtest_submit
submit_and_follow = helpers.submit_and_follow

Expand Down
2 changes: 1 addition & 1 deletion ckanext/example_iuploader/test/test_plugin.py
Expand Up @@ -6,6 +6,7 @@
from mock import patch
from nose.tools import (
assert_equal,
assert_in,
assert_is_instance
)
from pyfakefs import fake_filesystem
Expand All @@ -19,7 +20,6 @@
import ckan.tests.helpers as helpers
import ckanext.example_iuploader.plugin as plugin

assert_in = helpers.assert_in
webtest_submit = helpers.webtest_submit
submit_and_follow = helpers.submit_and_follow

Expand Down
5 changes: 1 addition & 4 deletions ckanext/example_theme/custom_emails/tests.py
Expand Up @@ -11,10 +11,7 @@
from ckan.tests.lib.test_mailer import MailerBase
import ckan.tests.helpers as helpers

from nose.tools import assert_equal


assert_in = helpers.assert_in
from nose.tools import assert_equal, assert_in


class TestExampleCustomEmailsPlugin(MailerBase):
Expand Down

0 comments on commit f8bd2cd

Please sign in to comment.