Support python 2.6

This commit is contained in:
Honza Kral
2013-08-27 04:07:52 +02:00
parent 87a09091ce
commit 158f6e6183
7 changed files with 19 additions and 17 deletions
+2 -2
View File
@@ -27,7 +27,7 @@ class ElasticsearchTestCase(TestCase):
self.assertEquals(count, self.client.transport.call_count) self.assertEquals(count, self.client.transport.call_count)
def assert_url_called(self, method, url, count=1): def assert_url_called(self, method, url, count=1):
self.assertIn((method, url), self.client.transport.calls) self.assertTrue((method, url) in self.client.transport.calls)
calls = self.client.transport.calls[(method, url)] calls = self.client.transport.calls[(method, url)]
self.assertEquals(count, len(calls)) self.assertEquals(count, len(calls))
return calls return calls
@@ -35,7 +35,7 @@ class ElasticsearchTestCase(TestCase):
class TestElasticsearchTestCase(ElasticsearchTestCase): class TestElasticsearchTestCase(ElasticsearchTestCase):
def test_our_transport_used(self): def test_our_transport_used(self):
self.assertIsInstance(self.client.transport, DummyTransport) self.assertTrue(isinstance(self.client.transport, DummyTransport))
def test_start_with_0_call(self): def test_start_with_0_call(self):
self.assert_call_count_equals(0) self.assert_call_count_equals(0)
+2 -1
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from unittest import TestCase, SkipTest from unittest import TestCase
from nose import SkipTest
from elasticsearch.client.utils import _make_path from elasticsearch.client.utils import _make_path
+1 -1
View File
@@ -91,5 +91,5 @@ class TestConnectionPool(TestCase):
self.assertEquals(3, pool.dead_count[42]) self.assertEquals(3, pool.dead_count[42])
pool.mark_live(42) pool.mark_live(42)
self.assertNotIn(42, pool.dead_count) self.assertFalse(42 in pool.dead_count)
+2 -1
View File
@@ -8,7 +8,8 @@ import requests
from elasticsearch import Elasticsearch from elasticsearch import Elasticsearch
from elasticsearch.exceptions import ConnectionError from elasticsearch.exceptions import ConnectionError
from unittest import SkipTest, TestCase from unittest import TestCase
from nose import SkipTest
data_dir = None data_dir = None
@@ -6,7 +6,7 @@ clients.
from os import walk, environ from os import walk, environ
from os.path import exists, join, dirname, pardir from os.path import exists, join, dirname, pardir
import yaml import yaml
from unittest import SkipTest from nose import SkipTest
from . import ElasticTestCase from . import ElasticTestCase
@@ -53,7 +53,7 @@ class YamlTestCase(ElasticTestCase):
# resolve variables # resolve variables
if isinstance(value, (type(u''), type(''))) and value.startswith('$'): if isinstance(value, (type(u''), type(''))) and value.startswith('$'):
value = value[1:] value = value[1:]
self.assertIn(value, self._state) self.assertTrue(value in self._state)
value = self._state[value] value = self._state[value]
return value return value
@@ -67,10 +67,10 @@ class YamlTestCase(ElasticTestCase):
step = step.replace('\1', '.') step = step.replace('\1', '.')
if step.isdigit(): if step.isdigit():
step = int(step) step = int(step)
self.assertIsInstance(value, list) self.assertTrue(isinstance(value, list))
self.assertGreater(len(value), step) self.assertTrue(len(value) > step)
else: else:
self.assertIn(step, value) self.assertTrue(step in value)
value = value[step] value = value[step]
return value return value
@@ -133,11 +133,11 @@ class YamlTestCase(ElasticTestCase):
def run_gt(self, action): def run_gt(self, action):
for key, value in action.items(): for key, value in action.items():
self.assertGreater(self._lookup(key), value) self.assertTrue(self._lookup(key) > value)
def run_lt(self, action): def run_lt(self, action):
for key, value in action.items(): for key, value in action.items():
self.assertLess(self._lookup(key), value) self.assertTrue(self._lookup(key) < value)
def run_set(self, action): def run_set(self, action):
for key, value in action.items(): for key, value in action.items():
@@ -5,7 +5,7 @@ from elasticsearch.transport import ADDRESS_RE
from . import ElasticTestCase from . import ElasticTestCase
from unittest import SkipTest from nose import SkipTest
class TestMemcachedConnection(ElasticTestCase): class TestMemcachedConnection(ElasticTestCase):
def setUp(self): def setUp(self):
+4 -4
View File
@@ -41,7 +41,7 @@ class TestTransport(TestCase):
def test_kwargs_passed_on_to_connection_pool(self): def test_kwargs_passed_on_to_connection_pool(self):
dt = object() dt = object()
t = Transport([{}], dead_timeout=dt) t = Transport([{}], dead_timeout=dt)
self.assertIs(dt, t.connection_pool.dead_timeout) self.assertTrue(dt is t.connection_pool.dead_timeout)
def test_custom_connection_class(self): def test_custom_connection_class(self):
class MyConnection(object): class MyConnection(object):
@@ -49,7 +49,7 @@ class TestTransport(TestCase):
self.kwargs = kwargs self.kwargs = kwargs
t = Transport([{}], connection_class=MyConnection) t = Transport([{}], connection_class=MyConnection)
self.assertEquals(1, len(t.connection_pool.connections)) self.assertEquals(1, len(t.connection_pool.connections))
self.assertIsInstance(t.connection_pool.connections[0], MyConnection) self.assertTrue(isinstance(t.connection_pool.connections[0], MyConnection))
def test_add_connection(self): def test_add_connection(self):
t = Transport([{}], randomize_hosts=False) t = Transport([{}], randomize_hosts=False)
@@ -98,7 +98,7 @@ class TestTransport(TestCase):
t.sniff_hosts() t.sniff_hosts()
self.assertEquals(1, len(t.connection_pool.connections)) self.assertEquals(1, len(t.connection_pool.connections))
self.assertIs(connection, t.get_connection()) self.assertTrue(connection is t.get_connection())
def test_sniff_on_fail_triggers_sniffing_on_fail(self): def test_sniff_on_fail_triggers_sniffing_on_fail(self):
t = Transport([{'exception': ConnectionError('abandon ship')}, {"data": CLUSTER_NODES}], t = Transport([{'exception': ConnectionError('abandon ship')}, {"data": CLUSTER_NODES}],
@@ -115,7 +115,7 @@ class TestTransport(TestCase):
for _ in range(4): for _ in range(4):
t.perform_request('GET', '/') t.perform_request('GET', '/')
self.assertEquals(1, len(t.connection_pool.connections)) self.assertEquals(1, len(t.connection_pool.connections))
self.assertIsInstance(t.get_connection(), DummyConnection) self.assertTrue(isinstance(t.get_connection(), DummyConnection))
t.last_sniff = time.time() - 5.1 t.last_sniff = time.time() - 5.1
t.perform_request('GET', '/') t.perform_request('GET', '/')