From 38ba61d5114586a67801c7ac5a4ba4b46c99da22 Mon Sep 17 00:00:00 2001 From: Honza Kral Date: Sun, 25 Aug 2013 18:01:45 +0200 Subject: [PATCH] Fix memcached tests for py3 --- elasticsearch/connection/memcached.py | 2 +- elasticsearch/connection/thrift.py | 2 +- elasticsearch/exceptions.py | 5 ++++- test_elasticsearch/test_server/test_memcached.py | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/elasticsearch/connection/memcached.py b/elasticsearch/connection/memcached.py index 153a2505..09f0c163 100644 --- a/elasticsearch/connection/memcached.py +++ b/elasticsearch/connection/memcached.py @@ -5,7 +5,7 @@ try: except ImportError: from urllib.parse import urlencode -from ..exceptions import TransportError, ConnectionError +from ..exceptions import TransportError, ConnectionError, ImproperlyConfigured from .pooling import PoolingConnection class MemcachedConnection(PoolingConnection): diff --git a/elasticsearch/connection/thrift.py b/elasticsearch/connection/thrift.py index 2aae067e..25e039a6 100644 --- a/elasticsearch/connection/thrift.py +++ b/elasticsearch/connection/thrift.py @@ -12,7 +12,7 @@ try: except ImportError: THRIFT_AVAILABLE = False -from ..exceptions import ConnectionError +from ..exceptions import ConnectionError, ImproperlyConfigured from .pooling import PoolingConnection class ThriftConnection(PoolingConnection): diff --git a/elasticsearch/exceptions.py b/elasticsearch/exceptions.py index b08f4704..47191aa5 100644 --- a/elasticsearch/exceptions.py +++ b/elasticsearch/exceptions.py @@ -1,4 +1,7 @@ -__all__ = ['ElastiSearchException', 'SerializationError', 'TransportError', 'NotFoundError'] +__all__ = ['ImproperlyConfigured', 'ElastiSearchException', 'SerializationError', 'TransportError', 'NotFoundError'] + +class ImproperlyConfigured(Exception): + pass class ElastiSearchException(Exception): pass diff --git a/test_elasticsearch/test_server/test_memcached.py b/test_elasticsearch/test_server/test_memcached.py index cab84ae0..c91293c2 100644 --- a/test_elasticsearch/test_server/test_memcached.py +++ b/test_elasticsearch/test_server/test_memcached.py @@ -9,6 +9,10 @@ from unittest import SkipTest class TestMemcachedConnection(ElasticTestCase): def setUp(self): + try: + import pylibmc + except ImportError: + raise SkipTest("No pylibmc.") super(TestMemcachedConnection, self).setUp() nodes = self.client.cluster.node_info() for node_id, node_info in nodes["nodes"].items():