Use unittest2 even for python 2.6

This commit is contained in:
Honza Kral
2013-08-28 19:11:28 +02:00
parent d180e62a99
commit fe7cc106f6
11 changed files with 26 additions and 14 deletions
+6
View File
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from os.path import join, dirname
from setuptools import setup
import sys
VERSION = (0, 0, 1)
@@ -21,6 +23,10 @@ tests_require = [
'mock',
]
# use external unittest for 2.6
if sys.version_info[:2] == (2, 6):
tests_require.append('unittest2')
setup(
name = 'elasticsearch',
description = "Python client for Elasticsearch",
+5 -1
View File
@@ -1,5 +1,9 @@
from unittest import TestCase
from collections import defaultdict
try:
# python 2.6
from unittest2 import TestCase, SkipTest
except ImportError:
from unittest import TestCase, SkipTest
from elasticsearch import Elasticsearch
+2 -2
View File
@@ -1,7 +1,7 @@
from unittest import TestCase
from elasticsearch.client import _normalize_hosts
from ..test_cases import TestCase
class TestNormalizeHosts(TestCase):
def test_none_uses_defaults(self):
self.assertEquals([{}], _normalize_hosts(None))
+2 -2
View File
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from unittest import TestCase, SkipTest
from elasticsearch.client.utils import _make_path
from ..test_cases import TestCase, SkipTest
class TestMakePath(TestCase):
def test_handles_unicode(self):
id = u"中文"
+2 -2
View File
@@ -1,11 +1,11 @@
import re
from unittest import TestCase
from mock import Mock, patch
from elasticsearch.exceptions import TransportError
from elasticsearch.connection import RequestsHttpConnection
from .test_cases import TestCase
class TestRequestsConnection(TestCase):
def _get_mock_connection(self, connection_params={}, status_code=200, response_body=u'{}'):
con = RequestsHttpConnection(**connection_params)
+2 -1
View File
@@ -1,8 +1,9 @@
import time
from unittest import TestCase
from elasticsearch.connection_pool import ConnectionPool, RoundRobinSelector
from .test_cases import TestCase
class TestConnectionPool(TestCase):
def test_default_round_robin(self):
pool = ConnectionPool([(x, {}) for x in range(100)])
+2 -1
View File
@@ -1,9 +1,10 @@
from datetime import datetime
from unittest import TestCase
from elasticsearch.serializer import JSONSerializer
from elasticsearch.exceptions import SerializationError
from .test_cases import TestCase
class TestJSONSerializer(TestCase):
def test_datetime_serialization(self):
self.assertEquals(u'{"d": "2010-10-01T02:30:00"}', JSONSerializer().dumps({'d': datetime(2010, 10, 1, 2, 30)}))
+1 -1
View File
@@ -8,7 +8,7 @@ import requests
from elasticsearch import Elasticsearch
from elasticsearch.exceptions import ConnectionError
from unittest import SkipTest, TestCase
from ..test_cases import TestCase, SkipTest
data_dir = None
@@ -6,8 +6,8 @@ clients.
from os import walk, environ
from os.path import exists, join, dirname, pardir
import yaml
from unittest import SkipTest
from ..test_cases import SkipTest
from . import ElasticTestCase
# some params had to be changed in python, keep track of them so we can rename
@@ -4,8 +4,7 @@ from elasticsearch import Elasticsearch, MemcachedConnection, NotFoundError
from elasticsearch.transport import ADDRESS_RE
from . import ElasticTestCase
from unittest import SkipTest
from ..test_cases import SkipTest
class TestMemcachedConnection(ElasticTestCase):
def setUp(self):
+2 -1
View File
@@ -1,10 +1,11 @@
import time
from unittest import TestCase
from elasticsearch.transport import Transport
from elasticsearch.connection import Connection
from elasticsearch.exceptions import ConnectionError
from .test_cases import TestCase
class DummyConnection(Connection):
def __init__(self, **kwargs):
self.exception = kwargs.pop('exception', None)