From 801ea73a691539fd1c9f4ebe006cf8d6eb52c5b1 Mon Sep 17 00:00:00 2001 From: David Coles Date: Tue, 20 Oct 2015 10:57:46 -0700 Subject: [PATCH] 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 --- src/test/pybind/test_rados.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/pybind/test_rados.py b/src/test/pybind/test_rados.py index 11457a7bc3bd0..ebc4e8fcdee65 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') -- 2.39.5