diff options
author | Noel Power <noel.power@suse.com> | 2018-11-04 17:32:19 +0000 |
---|---|---|
committer | Noel Power <npower@samba.org> | 2018-12-10 10:38:21 +0100 |
commit | a25bd836ee601ca704d2899f17259b9b5cd440cf (patch) | |
tree | 2d80355287e7640f5c837f697a7190e0bcd5a5d8 /python | |
parent | 0d73a2b0a29c108c3a0efbbe0473142046302b71 (diff) | |
download | samba-a25bd836ee601ca704d2899f17259b9b5cd440cf.tar.gz |
python/samba/tests: PY3 port samba.tests.dns
Misc hanges needed to get make test TEST=samba.tests.dns &
samb.tests.dns_fowarder to run and pass under PY3
* socket.send needs bytes not string
* rec.dwTimeStamp expects int not float (in PY3 / operator
will give float results, for int use '//' instead)
* re.match using bytes needs a bytes search term
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/tests/dns.py | 6 | ||||
-rw-r--r-- | python/samba/tests/dns_forwarder.py | 14 | ||||
-rw-r--r-- | python/samba/tests/dns_forwarder_helpers/server.py | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py index 1bf57e2aad0..8762abf8f59 100644 --- a/python/samba/tests/dns.py +++ b/python/samba/tests/dns.py @@ -988,7 +988,7 @@ class TestInvalidQueries(DNSTest): try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) s.connect((self.server_ip, 53)) - s.send("", 0) + s.send(b"", 0) finally: if s is not None: s.close() @@ -1253,13 +1253,13 @@ class TestZones(DNSTest): def mod_ts(rec): self.assertTrue(rec.dwTimeStamp > 0) - rec.dwTimeStamp -= interval / 2 + rec.dwTimeStamp -= interval // 2 self.ldap_modify_dnsrecs(name, mod_ts) update_during_norefresh = self.dns_update_record(name, txt) def mod_ts(rec): self.assertTrue(rec.dwTimeStamp > 0) - rec.dwTimeStamp -= interval + interval / 2 + rec.dwTimeStamp -= interval + interval // 2 self.ldap_modify_dnsrecs(name, mod_ts) update_during_refresh = self.dns_update_record(name, txt) self.assertEqual(update_during_norefresh.dwTimeStamp, diff --git a/python/samba/tests/dns_forwarder.py b/python/samba/tests/dns_forwarder.py index 35f1c1974be..8178678e885 100644 --- a/python/samba/tests/dns_forwarder.py +++ b/python/samba/tests/dns_forwarder.py @@ -189,7 +189,7 @@ class TestDnsForwarding(DNSTest): time.sleep(0.05) s.connect((host, port)) try: - s.send('timeout 0', 0) + s.send(b'timeout 0', 0) except socket.error as e: if e.errno in (errno.ECONNREFUSED, errno.EHOSTUNREACH): continue @@ -206,7 +206,7 @@ class TestDnsForwarding(DNSTest): def test_comatose_forwarder(self): s = self.start_toy_server(dns_servers[0], 53, 'forwarder1') - s.send("timeout 1000000", 0) + s.send(b"timeout 1000000", 0) # make DNS query name = "an-address-that-will-not-resolve" @@ -332,7 +332,7 @@ class TestDnsForwarding(DNSTest): def test_single_forwarder_waiting_forever(self): s = self.start_toy_server(dns_servers[0], 53, 'forwarder1') - s.send('timeout 10000', 0) + s.send(b'timeout 10000', 0) ad = contact_real_server(server_ip, 53) name = "dsfsfds.dsfsdfs" p = self.make_name_packet(dns.DNS_OPCODE_QUERY) @@ -361,7 +361,7 @@ class TestDnsForwarding(DNSTest): return s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1') s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') - s1.send('timeout 1000', 0) + s1.send(b'timeout 1000', 0) ad = contact_real_server(server_ip, 53) name = "dsfsfds.dsfsdfs" p = self.make_name_packet(dns.DNS_OPCODE_QUERY) @@ -419,8 +419,8 @@ class TestDnsForwarding(DNSTest): return s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1') s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') - s1.send('timeout 1.5', 0) - s2.send('timeout 1.5', 0) + s1.send(b'timeout 1.5', 0) + s2.send(b'timeout 1.5', 0) ad = contact_real_server(server_ip, 53) name = "dsfsfds.dsfsdfs" p = self.make_name_packet(dns.DNS_OPCODE_QUERY) @@ -505,7 +505,7 @@ class TestDnsForwarding(DNSTest): return s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1') s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') - s1.send('timeout 10000', 0) + s1.send(b'timeout 10000', 0) name = 'resolve.cname.%s' % self.get_dns_domain() self.make_cname_update(name, "dsfsfds.dsfsdfs") diff --git a/python/samba/tests/dns_forwarder_helpers/server.py b/python/samba/tests/dns_forwarder_helpers/server.py index d7a89ca995b..32b0ffe052a 100644 --- a/python/samba/tests/dns_forwarder_helpers/server.py +++ b/python/samba/tests/dns_forwarder_helpers/server.py @@ -76,7 +76,7 @@ class DnsHandler(SocketServer.BaseRequestHandler): debug("%s: %s wrote:" % (SERVER_ID, self.client_address[0])) global timeout - m = re.match('^timeout\s+([\d.]+)$', data.strip()) + m = re.match(b'^timeout\s+([\d.]+)$', data.strip()) if m: timeout = float(m.group(1)) debug("timing out at %s" % timeout) |