]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/pybind/test_rados: always pass bytes to rados.Object.set_xattr() 31044/head
authorKefu Chai <kchai@redhat.com>
Tue, 22 Oct 2019 04:44:35 +0000 (12:44 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 22 Oct 2019 08:05:26 +0000 (16:05 +0800)
> an empty '' is of type str, not bytes.

python3 says. so let's be more explicit.

this change address failures like:
```
======================================================================
ERROR: test_rados.TestIoctx.test_obj_xattrs
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 197, in
runTest
    self.test(*self.arg)
  File "/var/ssd/ceph/src/test/pybind/test_rados.py", line 380, in
test_obj_xattrs
    obj.set_xattr(key, value)
  File "rados.pyx", line 4119, in rados.set_object_locator.retfunc
  File "rados.pyx", line 4129, in rados.set_object_namespace.retfunc
  File "rados.pyx", line 4204, in rados.Object.set_xattr
  File "rados.pyx", line 572, in rados.requires.wrapper.validate_func
  File "rados.pyx", line 560, in rados.requires.check_type
TypeError: xattr_value must be bytes
```

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/pybind/test_rados.py

index 967fc0adae5b49750289f2cb2fcf793fdcc96513..bd685b3c6172e9cccd03f499821ad362fa3e2f6e 100644 (file)
@@ -362,7 +362,7 @@ class TestIoctx(object):
                 ('ns1', 'ns1-c'), ('ns1', 'ns1-d')])
 
     def test_xattrs(self):
-        xattrs = dict(a=b'1', b=b'2', c=b'3', d=b'a\0b', e=b'\0', f='')
+        xattrs = dict(a=b'1', b=b'2', c=b'3', d=b'a\0b', e=b'\0', f=b'')
         self.ioctx.write('abc', b'')
         for key, value in xattrs.items():
             self.ioctx.set_xattr('abc', key, value)
@@ -373,7 +373,7 @@ class TestIoctx(object):
         eq(stored_xattrs, xattrs)
 
     def test_obj_xattrs(self):
-        xattrs = dict(a=b'1', b=b'2', c=b'3', d=b'a\0b', e=b'\0', f='')
+        xattrs = dict(a=b'1', b=b'2', c=b'3', d=b'a\0b', e=b'\0', f=b'')
         self.ioctx.write('abc', b'')
         obj = list(self.ioctx.list_objects())[0]
         for key, value in xattrs.items():