]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use six.StringIO/BytesIO instead of StringIO.StringIO
authorHe Yongli <yongli.he@intel.com>
Mon, 17 Feb 2014 02:28:03 +0000 (10:28 +0800)
committerHe Yongli <yongli.he@intel.com>
Mon, 17 Feb 2014 03:13:33 +0000 (11:13 +0800)
to keep Python 3.x compatibility, use six.StringIO/BytesIO to
replace StringIO.StringIO

StringIO works for unicode
BytesIO works for bytes

Change-Id: I3892098e31d8d6984d58136110aae653dc4047ab
Closes-Bug: #1280100

neutron/agent/linux/dhcp.py
neutron/tests/unit/test_policy.py

index f3d8e814609c69c13397703fdbe63942ea0a8111..8850306e7b814af9a530cf69b698272be8b25cc6 100644 (file)
@@ -21,7 +21,6 @@ import os
 import re
 import shutil
 import socket
-import StringIO
 import sys
 import uuid
 
@@ -413,7 +412,7 @@ class Dnsmasq(DhcpLocalProcess):
     def _output_hosts_file(self):
         """Writes a dnsmasq compatible hosts file."""
         r = re.compile('[:.]')
-        buf = StringIO.StringIO()
+        buf = six.StringIO()
 
         for port in self.network.ports:
             for alloc in port.fixed_ips:
index 22a7ccad6ac0e6f834c2092a77909cb961c16787..81fe7dfad563d0ea2b5e77f7b0947a79b0a35703 100644 (file)
 """Test of Policy Engine For Neutron"""
 
 import json
-import StringIO
 import urllib2
 
 import fixtures
 import mock
+import six
 
 import neutron
 from neutron.api.v2 import attributes
@@ -120,7 +120,7 @@ class PolicyTestCase(base.BaseTestCase):
     def test_enforce_http_true(self):
 
         def fakeurlopen(url, post_data):
-            return StringIO.StringIO("True")
+            return six.StringIO("True")
 
         with mock.patch.object(urllib2, 'urlopen', new=fakeurlopen):
             action = "example:get_http"
@@ -131,7 +131,7 @@ class PolicyTestCase(base.BaseTestCase):
     def test_enforce_http_false(self):
 
         def fakeurlopen(url, post_data):
-            return StringIO.StringIO("False")
+            return six.StringIO("False")
 
         with mock.patch.object(urllib2, 'urlopen', new=fakeurlopen):
             action = "example:get_http"