From 237fa342f9bb459e2c82301a810c8a4a87c38e79 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Fri, 24 Jul 2015 16:19:19 +0200 Subject: [PATCH] Python 3: fix test_attributes In Python 3, strings have an __iter__ method, which makes convert_to_list fail. Change-Id: I2411ecd31d7d05ff6f0f004180edffc76d28573b Blueprint: neutron-python3 --- neutron/api/v2/attributes.py | 2 +- tox.ini | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/neutron/api/v2/attributes.py b/neutron/api/v2/attributes.py index 64a45e89105..6beb95b13a3 100644 --- a/neutron/api/v2/attributes.py +++ b/neutron/api/v2/attributes.py @@ -578,7 +578,7 @@ def convert_none_to_empty_dict(value): def convert_to_list(data): if data is None: return [] - elif hasattr(data, '__iter__'): + elif hasattr(data, '__iter__') and not isinstance(data, six.string_types): return list(data) else: return [data] diff --git a/tox.ini b/tox.ini index 37ddf17ccd0..39870fb3978 100644 --- a/tox.ini +++ b/tox.ini @@ -174,6 +174,7 @@ commands = python -m testtools.run \ neutron.tests.unit.api.rpc.handlers.test_securitygroups_rpc \ neutron.tests.unit.api.rpc.handlers.test_dvr_rpc \ neutron.tests.unit.api.rpc.agentnotifiers.test_dhcp_rpc_agent_api \ + neutron.tests.unit.api.v2.test_attributes \ neutron.tests.unit.agent.metadata.test_driver \ neutron.tests.unit.agent.test_rpc \ neutron.tests.unit.agent.test_securitygroups_rpc \