Compatibility with python 3.2

Now all the python 2/3 compatibility code is in elasticsearch.compat
Fixes #52
This commit is contained in:
Honza Král
2014-02-21 16:59:13 +01:00
parent d4aca61a41
commit a54d7035bb
15 changed files with 49 additions and 45 deletions
+4 -3
View File
@@ -1,16 +1,17 @@
# -*- coding: utf-8 -*-
from elasticsearch.client.utils import _make_path
from elasticsearch.compat import PY2, u
from ..test_cases import TestCase, SkipTest
class TestMakePath(TestCase):
def test_handles_unicode(self):
id = u"中文"
id = u("中文")
self.assertEquals('/some-index/type/%E4%B8%AD%E6%96%87', _make_path('some-index', 'type', id))
def test_handles_utf_encoded_string(self):
if type('') is type(u''):
if not PY2:
raise SkipTest('Only relevant for py2')
id = u"中文".encode('utf-8')
id = u("中文").encode('utf-8')
self.assertEquals('/some-index/type/%E4%B8%AD%E6%96%87', _make_path('some-index', 'type', id))