Kaynağa Gözat

Fixed python 3 compatibility in openstack tests.

nuwan_ag 10 yıl önce
ebeveyn
işleme
561bf45252

+ 2 - 2
cloudbridge/providers/openstack/resources.py

@@ -226,7 +226,7 @@ class OpenStackInstance(BaseInstance):
         # network label. Therefore, it's necessary to parse the address and
         # determine whether it's public or private
         return [address
-                for addresses in self._os_instance.networks.itervalues()
+                for _, addresses in self._os_instance.networks.items()
                 for address in addresses
                 if not ipaddress.ip_address(address).is_private]
 
@@ -236,7 +236,7 @@ class OpenStackInstance(BaseInstance):
         Get all the private IP addresses for this instance.
         """
         return [address
-                for addresses in self._os_instance.networks.itervalues()
+                for _, addresses in self._os_instance.networks.items()
                 for address in addresses
                 if ipaddress.ip_address(address).is_private]
 

+ 2 - 7
test/test_provider_object_store_service.py

@@ -1,9 +1,4 @@
-# Python 3 compatibility fix
-try:
-    from StringIO import StringIO
-except ImportError:
-    from io import StringIO
-
+from io import BytesIO
 import uuid
 
 from test.helpers import ProviderTestBase
@@ -103,7 +98,7 @@ class ProviderObjectStoreServiceTestCase(ProviderTestBase):
                 # types. Need to make this consistent - possibly provider
                 # multiple methods like upload_from_file, from_stream etc.
                 obj.upload(content)
-                target_stream = StringIO()
+                target_stream = BytesIO()
                 obj.download(target_stream)
                 self.assertEqual(target_stream.getvalue(), content)
                 obj.delete()