From: David Coles Date: Tue, 20 Oct 2015 17:57:46 +0000 (-0700) Subject: pybind: Add test for creating pool by raw UTF-8 X-Git-Tag: v10.0.1~80^2~7^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=801ea73a691539fd1c9f4ebe006cf8d6eb52c5b1;p=ceph.git pybind: Add test for creating pool by raw UTF-8 Some clients try providing non-ASCII pool names by sending raw encoded bytes. This check ensures that we still support this behaviour for Python 2. In Python 3, bytestrings will fail since strings are Unicode strings and thus clients should use Unicode escapes instead. Signed-off-by: David Coles --- diff --git a/src/test/pybind/test_rados.py b/src/test/pybind/test_rados.py index 11457a7bc3bd..ebc4e8fcdee6 100644 --- a/src/test/pybind/test_rados.py +++ b/src/test/pybind/test_rados.py @@ -7,6 +7,10 @@ import time import threading import json import errno +import sys + +# Are we running Python 2.x +_python2 = sys.hexversion < 0x03000000 def test_rados_init_error(): assert_raises(Error, Rados, conffile='', rados_id='admin', @@ -127,6 +131,16 @@ class TestRados(object): self.rados.create_pool('foo') self.rados.delete_pool('foo') + def test_create_utf8(self): + if _python2: + # Use encoded bytestring + poolname = b"\351\273\204" + else: + poolname = "\u9ec4" + self.rados.create_pool(poolname) + assert self.rados.pool_exists(u"\u9ec4") + self.rados.delete_pool(poolname) + def test_create_auid(self): self.rados.create_pool('foo', 100) assert self.rados.pool_exists('foo')