Add py3 compatibility related changes
1. Replace unicode with six.text_type 2. Replace iterator.next() with next(iterator) Partially-Implements: blueprint designate-py3 Change-Id: I32e38d48cdb25df7bec2f59e622cc7c7593a55d2
This commit is contained in:
parent
e674ec8e6d
commit
916dae4b06
@ -15,6 +15,8 @@
|
||||
|
||||
import gettext
|
||||
|
||||
import six
|
||||
|
||||
from designate import exceptions
|
||||
|
||||
_ = gettext.gettext
|
||||
@ -41,7 +43,7 @@ class InfobloxExceptionBase(exceptions.Backend):
|
||||
super(InfobloxExceptionBase, self).__init__(self.message)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.msg)
|
||||
return six.text_type(self.msg)
|
||||
|
||||
def use_fatal_exceptions(self):
|
||||
return False
|
||||
|
@ -56,7 +56,7 @@ class AgentRequestHandlerTest(AgentTestCase):
|
||||
"6f6d0000060001")
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': ["0.0.0.0", 1234]}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
def test_receive_notify_bad_notifier(self):
|
||||
@ -78,7 +78,7 @@ class AgentRequestHandlerTest(AgentTestCase):
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
# Bad 'requester'
|
||||
request.environ = {'addr': ["6.6.6.6", 1234]}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -108,7 +108,7 @@ class AgentRequestHandlerTest(AgentTestCase):
|
||||
designate.backend.agent_backend.impl_fake.FakeBackend,
|
||||
'find_domain_serial', return_value=None):
|
||||
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
def test_receive_create_bad_notifier(self):
|
||||
@ -130,7 +130,7 @@ class AgentRequestHandlerTest(AgentTestCase):
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
# Bad 'requester'
|
||||
request.environ = {'addr': ["6.6.6.6", 1234]}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -154,7 +154,7 @@ class AgentRequestHandlerTest(AgentTestCase):
|
||||
"00ff03ff00")
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': ["0.0.0.0", 1234]}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -178,7 +178,7 @@ class AgentRequestHandlerTest(AgentTestCase):
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
# Bad 'requester'
|
||||
request.environ = {'addr': ["6.6.6.6", 1234]}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -206,6 +206,6 @@ class AgentRequestHandlerTest(AgentTestCase):
|
||||
with mock.patch.object(
|
||||
designate.backend.agent_backend.impl_fake.FakeBackend,
|
||||
'find_domain_serial', return_value=None):
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
doaxfr.assert_called_with('example.com.', [], source="1.2.3.4")
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
@ -93,7 +93,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -116,7 +116,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -172,7 +172,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
with mock.patch.object(self.handler.storage, 'find_domain',
|
||||
return_value=domain):
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.mock_tg.add_thread.assert_called_with(
|
||||
self.handler.domain_sync, self.context, domain, [master])
|
||||
@ -213,7 +213,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
with mock.patch.object(self.handler.storage, 'find_domain',
|
||||
return_value=domain):
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
assert not self.mock_tg.add_thread.called
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
@ -251,7 +251,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
with mock.patch.object(self.handler.storage, 'find_domain',
|
||||
return_value=domain):
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
assert not self.mock_tg.add_thread.called
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
@ -277,7 +277,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
'context': self.context
|
||||
}
|
||||
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
assert not self.mock_tg.add_thread.called
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
@ -305,7 +305,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
'context': self.context
|
||||
}
|
||||
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
assert not self.mock_tg.add_thread.called
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
@ -329,7 +329,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -377,7 +377,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
"00000100010000292000000000000000")
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -408,7 +408,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -439,7 +439,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -507,7 +507,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
|
||||
response = self.handler(request).next().get_wire()
|
||||
response = next(self.handler(request)).get_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -572,12 +572,12 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
response_generator = self.handler(request)
|
||||
|
||||
# Validate the first response
|
||||
response_one = response_generator.next().get_wire()
|
||||
response_one = next(response_generator).get_wire()
|
||||
self.assertEqual(
|
||||
expected_response[0], binascii.b2a_hex(response_one))
|
||||
|
||||
# Validate the second response
|
||||
response_two = response_generator.next().get_wire()
|
||||
response_two = next(response_generator).get_wire()
|
||||
self.assertEqual(
|
||||
expected_response[1], binascii.b2a_hex(response_two))
|
||||
|
||||
@ -607,7 +607,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -630,7 +630,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
|
||||
request = dns.message.from_wire(binascii.a2b_hex(payload))
|
||||
request.environ = {'addr': self.addr, 'context': self.context}
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -670,7 +670,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
"0000010001c00c0001000100000e100004c0000205000029"
|
||||
"2000000000000000")
|
||||
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -691,7 +691,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
expected_response = ("c28981050001000000000001076578616d706c6503636f6d"
|
||||
"00000100010000292000000000000000")
|
||||
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
def test_dispatch_opcode_query_tsig_scope_zone(self):
|
||||
@ -736,7 +736,7 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
"0000010001c00c0001000100000e100004c0000205000029"
|
||||
"2000000000000000")
|
||||
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
||||
@ -757,5 +757,5 @@ class MdnsRequestHandlerTest(MdnsTestCase):
|
||||
expected_response = ("c28981050001000000000001076578616d706c6503636f6d"
|
||||
"00000100010000292000000000000000")
|
||||
|
||||
response = self.handler(request).next().to_wire()
|
||||
response = next(self.handler(request)).to_wire()
|
||||
self.assertEqual(expected_response, binascii.b2a_hex(response))
|
||||
|
Loading…
Reference in New Issue
Block a user