From 0e6257606a44dad2b793374235836c6cb4e09e86 Mon Sep 17 00:00:00 2001 From: shanyunfan33 Date: Fri, 24 Dec 2021 10:02:03 +0800 Subject: [PATCH] remove unicode from code remove unicode from code Change-Id: Ide37b3c1f8a2e2dcdcac0a2b0631cb197eca5baf --- doc/source/conf.py | 8 +++---- .../l2/extensions/test_fdb_population.py | 10 ++++---- .../unit/agent/test_securitygroups_rpc.py | 10 ++++---- neutron/tests/unit/api/v2/test_resource.py | 4 ++-- neutron/tests/unit/notifiers/test_nova.py | 8 +++---- .../ml2/drivers/l2pop/test_mech_driver.py | 12 +++++----- .../agent/test_ovs_neutron_agent.py | 2 +- .../tests/unit/plugins/ml2/test_managers.py | 2 +- .../services/logapi/common/test_db_api.py | 24 +++++++++---------- neutron/tests/unit/test_wsgi.py | 8 +++---- releasenotes/source/conf.py | 16 ++++++------- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index a9250c1ef43..0f0620f8c4f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -92,8 +92,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'Neutron' -copyright = u'2011-present, OpenStack Foundation.' +project = 'Neutron' +copyright = '2011-present, OpenStack Foundation.' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -216,8 +216,8 @@ htmlhelp_basename = 'neutrondoc' # (source start file, target name, title, author, # documentclass [howto/manual]). latex_documents = [ - ('pdf-index', 'doc-neutron.tex', u'Neutron Documentation', - u'Neutron development team', 'manual'), + ('pdf-index', 'doc-neutron.tex', 'Neutron Documentation', + 'Neutron development team', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py b/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py index 576c638440e..177d62141ab 100644 --- a/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py +++ b/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py @@ -33,11 +33,11 @@ from neutron.tests import base class FdbPopulationExtensionTestCase(base.BaseTestCase): - UPDATE_MSG = {u'device_owner': constants.DEVICE_OWNER_ROUTER_INTF, - u'physical_network': u'physnet1', - u'mac_address': u'fa:16:3e:ba:bc:21', - u'port_id': u'17ceda02-43e1-48d8-beb6-35885b20cae6'} - DELETE_MSG = {u'port_id': u'17ceda02-43e1-48d8-beb6-35885b20cae6'} + UPDATE_MSG = {'device_owner': constants.DEVICE_OWNER_ROUTER_INTF, + 'physical_network': 'physnet1', + 'mac_address': 'fa:16:3e:ba:bc:21', + 'port_id': '17ceda02-43e1-48d8-beb6-35885b20cae6'} + DELETE_MSG = {'port_id': '17ceda02-43e1-48d8-beb6-35885b20cae6'} def setUp(self): super(FdbPopulationExtensionTestCase, self).setUp() diff --git a/neutron/tests/unit/agent/test_securitygroups_rpc.py b/neutron/tests/unit/agent/test_securitygroups_rpc.py index 6ec543ddf14..e72050139fd 100644 --- a/neutron/tests/unit/agent/test_securitygroups_rpc.py +++ b/neutron/tests/unit/agent/test_securitygroups_rpc.py @@ -491,7 +491,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase): 'security_group_id': sg2_id}, {'direction': 'egress', 'ethertype': const.IPv6, 'security_group_id': sg2_id}, - {'direction': u'ingress', + {'direction': 'ingress', 'source_ip_prefix': port_fixed_ip2 + '/32', 'protocol': const.PROTO_NAME_TCP, 'ethertype': const.IPv4, @@ -553,13 +553,13 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase): 'stateful': True}, {'direction': 'egress', 'ethertype': const.IPv6, 'stateful': True}, - {'direction': u'ingress', + {'direction': 'ingress', 'protocol': const.PROTO_NAME_TCP, 'ethertype': const.IPv4, 'port_range_max': 25, 'port_range_min': 24, 'remote_group_id': sg2_id, 'stateful': True}, - {'direction': u'ingress', + {'direction': 'ingress', 'protocol': const.PROTO_NAME_TCP, 'ethertype': const.IPv4, 'port_range_max': 27, 'port_range_min': 26, @@ -694,13 +694,13 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase): 'stateful': True}, {'direction': 'egress', 'ethertype': const.IPv6, 'stateful': True}, - {'direction': u'ingress', + {'direction': 'ingress', 'protocol': const.PROTO_NAME_TCP, 'ethertype': const.IPv6, 'port_range_max': 22, 'port_range_min': 22, 'remote_group_id': sg1_id, 'stateful': True}, - {'direction': u'ingress', + {'direction': 'ingress', 'protocol': const.PROTO_NAME_TCP, 'ethertype': const.IPv6, 'port_range_max': 23, 'port_range_min': 23, diff --git a/neutron/tests/unit/api/v2/test_resource.py b/neutron/tests/unit/api/v2/test_resource.py index 0c9e4c5ec7f..2166ccc4c1e 100644 --- a/neutron/tests/unit/api/v2/test_resource.py +++ b/neutron/tests/unit/api/v2/test_resource.py @@ -138,7 +138,7 @@ class ResourceTestCase(base.BaseTestCase): return wsgi.JSONDeserializer() def test_unmapped_neutron_error_with_json(self): - msg = u'\u7f51\u7edc' + msg = '\u7f51\u7edc' class TestException(n_exc.NeutronException): message = msg @@ -181,7 +181,7 @@ class ResourceTestCase(base.BaseTestCase): str(wsgi.JSONDeserializer().deserialize(res.body))) def test_mapped_neutron_error_with_json(self): - msg = u'\u7f51\u7edc' + msg = '\u7f51\u7edc' class TestException(n_exc.NeutronException): message = msg diff --git a/neutron/tests/unit/notifiers/test_nova.py b/neutron/tests/unit/notifiers/test_nova.py index 10b2550857d..5d065336a93 100644 --- a/neutron/tests/unit/notifiers/test_nova.py +++ b/neutron/tests/unit/notifiers/test_nova.py @@ -139,7 +139,7 @@ class TestNovaNotify(base.BaseTestCase): device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87' returned_obj = {'port': {'device_owner': DEVICE_OWNER_COMPUTE, - 'id': u'bee50827-bcee-4cc8-91c1-a27b0ce54222', + 'id': 'bee50827-bcee-4cc8-91c1-a27b0ce54222', 'device_id': device_id}} expected_event = {'server_uuid': device_id, @@ -152,7 +152,7 @@ class TestNovaNotify(base.BaseTestCase): def test_create_floatingip_notify(self): device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87' returned_obj = {'floatingip': - {'port_id': u'bee50827-bcee-4cc8-91c1-a27b0ce54222'}} + {'port_id': 'bee50827-bcee-4cc8-91c1-a27b0ce54222'}} expected_event = {'server_uuid': device_id, 'name': 'network-changed', @@ -172,7 +172,7 @@ class TestNovaNotify(base.BaseTestCase): def test_delete_floatingip_notify(self): device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87' returned_obj = {'floatingip': - {'port_id': u'bee50827-bcee-4cc8-91c1-a27b0ce54222'}} + {'port_id': 'bee50827-bcee-4cc8-91c1-a27b0ce54222'}} expected_event = {'server_uuid': device_id, 'name': 'network-changed', @@ -202,7 +202,7 @@ class TestNovaNotify(base.BaseTestCase): def test_associate_floatingip_notify(self): device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87' returned_obj = {'floatingip': - {'port_id': u'5a39def4-3d3f-473d-9ff4-8e90064b9cc1'}} + {'port_id': '5a39def4-3d3f-473d-9ff4-8e90064b9cc1'}} original_obj = {'port_id': None} expected_event = {'server_uuid': device_id, diff --git a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py index 796106c38c8..ef694a059ec 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py @@ -375,8 +375,8 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase): host=HOST_4, refresh_tunnels=True) fanout_expected = {port['port']['network_id']: { - 'network_type': u'vxlan', - 'ports': {u'20.0.0.4': [('00:00:00:00:00:00', '0.0.0.0')]}, + 'network_type': 'vxlan', + 'ports': {'20.0.0.4': [('00:00:00:00:00:00', '0.0.0.0')]}, 'segment_id': 1}} self.mock_fanout.assert_called_with(mock.ANY, 'add_fdb_entries', @@ -1490,13 +1490,13 @@ class TestL2PopulationMechDriver(base.BaseTestCase): self.assertEqual(expected_result, result) def test_update_port_precommit_mac_address_changed_raises(self): - port = {'status': u'ACTIVE', + port = {'status': 'ACTIVE', 'device_owner': DEVICE_OWNER_COMPUTE, - 'mac_address': u'12:34:56:78:4b:0e', - 'id': u'1'} + 'mac_address': '12:34:56:78:4b:0e', + 'id': '1'} original_port = port.copy() - original_port['mac_address'] = u'12:34:56:78:4b:0f' + original_port['mac_address'] = '12:34:56:78:4b:0f' with mock.patch.object(driver_context.segments_db, 'get_network_segments'): diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index 46d78711606..7f073d0cf2b 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -2619,7 +2619,7 @@ class TestOvsNeutronAgent(object): self.assertRaises(ValueError, self._make_agent) def test__check_bridge_datapath_id(self): - datapath_id = u'0000622486fa3f42' + datapath_id = '0000622486fa3f42' datapath_ids_set = set() for i in range(5): dpid = format((i << 48) + int(datapath_id, 16), '0x').zfill(16) diff --git a/neutron/tests/unit/plugins/ml2/test_managers.py b/neutron/tests/unit/plugins/ml2/test_managers.py index 2cc58080214..784a9fbbef4 100644 --- a/neutron/tests/unit/plugins/ml2/test_managers.py +++ b/neutron/tests/unit/plugins/ml2/test_managers.py @@ -167,7 +167,7 @@ class TestManagers(base.BaseTestCase): cfg.CONF.set_override('mechanism_drivers', ['faulty_agent'], group='ml2') self.assertRaises(SystemExit, managers.MechanismManager) - mock_log.assert_called_once_with(u"The '%(entrypoint)s' entrypoint " + mock_log.assert_called_once_with("The '%(entrypoint)s' entrypoint " "could not be loaded for the " "following reason: '%(reason)s'.", {'entrypoint': mock.ANY, diff --git a/neutron/tests/unit/services/logapi/common/test_db_api.py b/neutron/tests/unit/services/logapi/common/test_db_api.py index efbb25c6cca..6c73539c459 100644 --- a/neutron/tests/unit/services/logapi/common/test_db_api.py +++ b/neutron/tests/unit/services/logapi/common/test_db_api.py @@ -237,20 +237,20 @@ class LoggingRpcCallbackTestCase(test_sg.SecurityGroupDBTestCase): 'port_id': port_id, 'security_group_rules': [ {'direction': 'egress', - 'ethertype': u'IPv4', + 'ethertype': 'IPv4', 'security_group_id': sg_id}, {'direction': 'egress', - 'ethertype': u'IPv6', + 'ethertype': 'IPv6', 'security_group_id': sg_id}, {'direction': 'ingress', - 'ethertype': u'IPv4', + 'ethertype': 'IPv4', 'port_range_max': 22, 'port_range_min': 22, - 'protocol': u'tcp', + 'protocol': 'tcp', 'security_group_id': sg_id}, {'direction': 'egress', - 'ethertype': u'IPv4', - 'protocol': u'tcp', + 'ethertype': 'IPv4', + 'protocol': 'tcp', 'dest_ip_prefix': net_utils.AuthenticIPNetwork( '10.0.0.1/32'), @@ -312,23 +312,23 @@ class LoggingRpcCallbackTestCase(test_sg.SecurityGroupDBTestCase): 'port_id': port_id, 'security_group_rules': [ {'direction': 'egress', - 'ethertype': u'IPv4', + 'ethertype': 'IPv4', 'security_group_id': sg_id}, {'direction': 'egress', - 'ethertype': u'IPv6', + 'ethertype': 'IPv6', 'security_group_id': sg_id}, {'direction': 'ingress', - 'ethertype': u'IPv4', + 'ethertype': 'IPv4', 'port_range_max': 13, 'port_range_min': 11, - 'protocol': u'tcp', + 'protocol': 'tcp', 'source_ip_prefix': net_utils.AuthenticIPNetwork( '10.0.0.1/32'), 'security_group_id': sg_id}, {'direction': 'egress', - 'ethertype': u'IPv4', - 'protocol': u'icmp', + 'ethertype': 'IPv4', + 'protocol': 'icmp', 'security_group_id': sg_id}] }], 'project_id': tenant_id diff --git a/neutron/tests/unit/test_wsgi.py b/neutron/tests/unit/test_wsgi.py index b649765a869..c107c80639f 100644 --- a/neutron/tests/unit/test_wsgi.py +++ b/neutron/tests/unit/test_wsgi.py @@ -260,7 +260,7 @@ class SerializerTest(base.BaseTestCase): serializer = wsgi.Serializer() result = serializer.deserialize(data_string, content_type) - self.assertEqual({'body': {u'servers': [u'test=pass']}}, result) + self.assertEqual({'body': {'servers': ['test=pass']}}, result) class RequestDeserializerTest(testtools.TestCase): @@ -520,7 +520,7 @@ class JSONDictSerializerTest(base.BaseTestCase): self.assertEqual(expected_json, result) def test_json_with_unicode(self): - input_dict = dict(servers=dict(a=(2, u'\u7f51\u7edc'))) + input_dict = dict(servers=dict(a=(2, '\u7f51\u7edc'))) expected_json = b'{"servers":{"a":[2,"\\u7f51\\u7edc"]}}' serializer = wsgi.JSONDictSerializer() result = serializer.serialize(input_dict) @@ -572,14 +572,14 @@ class JSONDeserializerTest(base.BaseTestCase): def test_json_with_utf8(self): data = b'{"a": "\xe7\xbd\x91\xe7\xbb\x9c"}' - as_dict = {'body': {'a': u'\u7f51\u7edc'}} + as_dict = {'body': {'a': '\u7f51\u7edc'}} deserializer = wsgi.JSONDeserializer() self.assertEqual(as_dict, deserializer.deserialize(data)) def test_json_with_unicode(self): data = b'{"a": "\u7f51\u7edc"}' - as_dict = {'body': {'a': u'\u7f51\u7edc'}} + as_dict = {'body': {'a': '\u7f51\u7edc'}} deserializer = wsgi.JSONDeserializer() self.assertEqual(as_dict, deserializer.deserialize(data)) diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 2eb357ee04a..aa2633bc5e4 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -60,8 +60,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'Neutron Release Notes' -copyright = u'2015, Neutron Developers' +project = 'Neutron Release Notes' +copyright = '2015, Neutron Developers' # Release notes are version independent # The short X.Y version. @@ -209,8 +209,8 @@ latex_elements = { # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'NeutronReleaseNotes.tex', - u'Neutron Release Notes Documentation', - u'Neutron Developers', 'manual'), + 'Neutron Release Notes Documentation', + 'Neutron Developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -239,8 +239,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'neutronreleasenotes', u'Neutron Release Notes Documentation', - [u'Neutron Developers'], 1) + ('index', 'neutronreleasenotes', 'Neutron Release Notes Documentation', + ['Neutron Developers'], 1) ] # If true, show URL addresses after external links. @@ -253,8 +253,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'NeutronReleaseNotes', u'Neutron Release Notes Documentation', - u'Neutron Developers', 'NeutronReleaseNotes', + ('index', 'NeutronReleaseNotes', 'Neutron Release Notes Documentation', + 'Neutron Developers', 'NeutronReleaseNotes', 'One line description of project.', 'Miscellaneous'), ]