Skip to content

Commit

Permalink
Merge pull request #3127 from k-nut/3126-remove-python-2.6-support
Browse files Browse the repository at this point in the history
Remove Python 2.6 compability
  • Loading branch information
amercader committed Jun 21, 2016
2 parents 7529b0d + 9ee75b5 commit 6d7a9c3
Show file tree
Hide file tree
Showing 27 changed files with 31 additions and 151 deletions.
47 changes: 0 additions & 47 deletions ckan/lib/util.py

This file was deleted.

12 changes: 2 additions & 10 deletions ckan/model/extension.py
Expand Up @@ -4,23 +4,17 @@
Provides bridges between the model and plugin PluginImplementationss
"""
import logging
from operator import methodcaller

from sqlalchemy.orm.interfaces import MapperExtension
from sqlalchemy.orm.session import SessionExtension

import ckan.plugins as plugins

try:
from operator import methodcaller
except ImportError:
def methodcaller(name, *args, **kwargs):
"Replaces stdlib operator.methodcaller in python <2.6"
def caller(obj):
return getattr(obj, name)(*args, **kwargs)
return caller

log = logging.getLogger(__name__)


class ObserverNotifier(object):
"""
Mixin for hooking into SQLAlchemy
Expand Down Expand Up @@ -93,7 +87,6 @@ def notify_observers(self, func):
for observer in plugins.PluginImplementations(plugins.ISession):
func(observer)


def after_begin(self, session, transaction, connection):
return self.notify_observers(
methodcaller('after_begin', session, transaction, connection)
Expand Down Expand Up @@ -123,4 +116,3 @@ def after_rollback(self, session):
return self.notify_observers(
methodcaller('after_rollback', session)
)

1 change: 0 additions & 1 deletion ckan/pastertemplates/template/+dot+travis.yml_tmpl
@@ -1,7 +1,6 @@
language: python
sudo: required
python:
- "2.6"
- "2.7"
env: PGVERSION=9.1
install:
Expand Down
1 change: 0 additions & 1 deletion ckan/pastertemplates/template/setup.py_tmpl
Expand Up @@ -43,7 +43,6 @@ setup(

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
],

Expand Down
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
1 change: 0 additions & 1 deletion ckan/tests/legacy/test_coding_standards.py
Expand Up @@ -488,7 +488,6 @@ class TestPep8(object):
'ckan/model/authz.py',
'ckan/model/dashboard.py',
'ckan/model/domain_object.py',
'ckan/model/extension.py',
'ckan/model/follower.py',
'ckan/model/group.py',
'ckan/model/group_extra.py',
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
10 changes: 6 additions & 4 deletions ckan/tests/test_coding_standards.py
Expand Up @@ -15,8 +15,6 @@
import re
import subprocess

import ckan.lib.util as util


def test_building_the_docs():
'''There should be no warnings or errors when building the Sphinx docs.
Expand All @@ -28,8 +26,12 @@ def test_building_the_docs():
'''
try:
output = util.check_output(
['python', 'setup.py', 'build_sphinx', '--all-files', '--fresh-env'],
output = subprocess.check_output(
['python',
'setup.py',
'build_sphinx',
'--all-files',
'--fresh-env'],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as err:
assert False, (
Expand Down
17 changes: 0 additions & 17 deletions ckanext/datapusher/tests/test.py
Expand Up @@ -4,7 +4,6 @@
import httpretty
import httpretty.core
import nose
import sys
import datetime

import pylons
Expand Down Expand Up @@ -56,19 +55,12 @@ def __getattr__(self, attr):
httpretty.core.fakesock.socket = HTTPrettyFix


# avoid hanging tests https://github.com/gabrielfalcao/HTTPretty/issues/34
if sys.version_info < (2, 7, 0):
import socket
socket.setdefaulttimeout(1)


class TestDatastoreCreate(tests.WsgiAppCase):
sysadmin_user = None
normal_user = None

@classmethod
def setup_class(cls):

wsgiapp = middleware.make_app(config['global_conf'], **config)
cls.app = paste.fixture.TestApp(wsgiapp)
if not tests.is_datastore_supported():
Expand All @@ -84,20 +76,11 @@ def setup_class(cls):
set_url_type(
model.Package.get('annakarenina').resources, cls.sysadmin_user)

# Httpretty crashes with Solr on Python 2.6,
# skip the tests
if (sys.version_info[0] == 2 and sys.version_info[1] == 6):
raise nose.SkipTest()

@classmethod
def teardown_class(cls):
rebuild_all_dbs(cls.Session)
p.unload('datastore')
p.unload('datapusher')
# Reenable Solr indexing
if (sys.version_info[0] == 2 and sys.version_info[1] == 6
and not p.plugin_loaded('synchronous_search')):
p.load('synchronous_search')

def test_create_ckan_resource_in_package(self):
package = model.Package.get('annakarenina')
Expand Down
6 changes: 0 additions & 6 deletions ckanext/datastore/tests/test_create.py
Expand Up @@ -22,12 +22,6 @@
from ckanext.datastore.tests.helpers import rebuild_all_dbs, set_url_type


# avoid hanging tests https://github.com/gabrielfalcao/HTTPretty/issues/34
if sys.version_info < (2, 7, 0):
import socket
socket.setdefaulttimeout(1)


class TestDatastoreCreateNewTests(object):
@classmethod
def setup_class(cls):
Expand Down

0 comments on commit 6d7a9c3

Please sign in to comment.