]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commit
Port objects unit tests to Python 3
authorVictor Stinner <vstinner@redhat.com>
Tue, 26 Jan 2016 14:48:34 +0000 (15:48 +0100)
committerVictor Stinner <vstinner@redhat.com>
Mon, 8 Feb 2016 09:47:53 +0000 (10:47 +0100)
commitf3dc1a0c54e78a4948acbdd3b94b2b2b2eb9ae78
treed678e9da4f67ef5cf9b3735a0ff4ca45d5d57e9a
parentd5ccbf9c28fd8fa869db8e7e9847ed74d3c0b49d
Port objects unit tests to Python 3

* BaseObjectsTestCase._compare(): replace hasattr() with getattr()
  and a white list of expected exceptions. On Python 2, hasattr()
  ignores *all* exceptions and so may hide real bugs.
* Mocks: except a call to obj.__bool__() rather than
  obj.__nonzero__() on Python 3. bool(obj) now calls obj.__bool__()
  on Python 3.
* Replace dict.keys() with list(dict.keys()) to get a list on Python
  3. On Python 3, dict.keys() now returns a view.
* JSON/base64:

  * Replace jsonutils.dumps() with jsonutils.dump_as_bytes() to get
    JSON as bytes
  * Replace base64.encodestring() with oslo_serialization.base64.encode_as_text() to get
    base64 as bytes
  * Replace base64.decodestring() with
    oslo_serialization.base64.decode_as_text() to accept Unicode and
    return Unicode

* tests-py3.txt: add cinder.tests.unit.objects.test_* (11 files)

Partial-Implements: blueprint cinder-python3
Change-Id: I9ce7753eb947bf9a5c91e643f5c65156c8e3f7cc
13 files changed:
cinder/objects/backup.py
cinder/tests/unit/api/contrib/test_backups.py
cinder/tests/unit/objects/__init__.py
cinder/tests/unit/objects/test_backup.py
cinder/tests/unit/objects/test_base.py
cinder/tests/unit/objects/test_cgsnapshot.py
cinder/tests/unit/objects/test_consistencygroup.py
cinder/tests/unit/objects/test_service.py
cinder/tests/unit/objects/test_snapshot.py
cinder/tests/unit/objects/test_volume.py
cinder/tests/unit/objects/test_volume_attachment.py
cinder/tests/unit/objects/test_volume_type.py
tests-py3.txt