summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-02-27 14:03:24 +0100
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-02-27 14:03:24 +0100
commitad48c40528c67639a1b57d0b89b42ccf76954ae1 (patch)
tree5664625483df8e864b48d08c555d7c6ab3138875
parent221eb702651ffc747fca39a551291a81beee92cd (diff)
downloadoslo-serialization-ad48c40528c67639a1b57d0b89b42ccf76954ae1.tar.gz
Use six.moves.xmlrpc_client instead of xmlrpclib
Implement jaypipes' note about this, to improve Python 2/3 compatibility. Change-Id: I89d27045142dd46ed8d91871ce3681ea9032cfe3
-rw-r--r--openstack/common/jsonutils.py10
-rw-r--r--tests/unit/test_jsonutils.py7
2 files changed, 2 insertions, 15 deletions
diff --git a/openstack/common/jsonutils.py b/openstack/common/jsonutils.py
index a5f5c12..765e689 100644
--- a/openstack/common/jsonutils.py
+++ b/openstack/common/jsonutils.py
@@ -36,17 +36,9 @@ import functools
import inspect
import itertools
import json
-try:
- import xmlrpclib
-except ImportError:
- # NOTE(jaypipes): xmlrpclib was renamed to xmlrpc.client in Python3
- # however the function and object call signatures
- # remained the same. This whole try/except block should
- # be removed and replaced with a call to six.moves once
- # six 1.4.2 is released. See http://bit.ly/1bqrVzu
- import xmlrpc.client as xmlrpclib
import six
+import six.moves.xmlrpc_client as xmlrpclib
from openstack.common import gettextutils
from openstack.common import importutils
diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py
index 6700924..9eb0538 100644
--- a/tests/unit/test_jsonutils.py
+++ b/tests/unit/test_jsonutils.py
@@ -14,14 +14,10 @@
# under the License.
import datetime
-try:
- import xmlrpclib
-except ImportError:
- xmlrpclib = None
import netaddr
import six
-import testtools
+import six.moves.xmlrpc_client as xmlrpclib
from openstack.common import gettextutils
from openstack.common import jsonutils
@@ -67,7 +63,6 @@ class ToPrimitiveTestCase(test.BaseTestCase):
x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7)
self.assertEqual(jsonutils.to_primitive(x, convert_datetime=False), x)
- @testtools.skipUnless(xmlrpclib, "xmlrpclib not available")
def test_DateTime(self):
x = xmlrpclib.DateTime()
x.decode("19710203T04:05:06")