diff options
author | Euclid Linden <euclid@lindenlab.com> | 2022-04-18 21:56:26 +0000 |
---|---|---|
committer | Euclid Linden <euclid@lindenlab.com> | 2022-04-18 21:56:26 +0000 |
commit | e71201ac125cab5f3d3cf7d6a30500253fc29d90 (patch) | |
tree | 270e46eb85dd46fb6962a36a9357dbf31c3afb29 /indra/llmessage | |
parent | 2d63d2044e0a00d1969c3da254e016a6e520c0d5 (diff) | |
parent | 035b1996df3f357b5060e3eb778588da5b9e7b37 (diff) |
Merged in DV528-merge-6.5.5 (pull request #945)
DRTVWR-528 merge up to 6.5.5
Diffstat (limited to 'indra/llmessage')
-rwxr-xr-x | indra/llmessage/tests/test_llsdmessage_peer.py | 6 | ||||
-rwxr-xr-x | indra/llmessage/tests/testrunner.py | 36 |
2 files changed, 21 insertions, 21 deletions
diff --git a/indra/llmessage/tests/test_llsdmessage_peer.py b/indra/llmessage/tests/test_llsdmessage_peer.py index 9cd2959ea1..5ba0749e31 100755 --- a/indra/llmessage/tests/test_llsdmessage_peer.py +++ b/indra/llmessage/tests/test_llsdmessage_peer.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """\ @file test_llsdmessage_peer.py @author Nat Goodspeed @@ -31,7 +31,7 @@ $/LicenseInfo$ import os import sys -from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler +from http.server import HTTPServer, BaseHTTPRequestHandler from llbase.fastest_elementtree import parse as xml_parse from llbase import llsd @@ -165,7 +165,7 @@ if __name__ == "__main__": # "Then there's Windows" # Instantiate a Server(TestHTTPRequestHandler) on the first free port # in the specified port range. - httpd, port = freeport(xrange(8000, 8020), make_server) + httpd, port = freeport(range(8000, 8020), make_server) # Pass the selected port number to the subject test program via the # environment. We don't want to impose requirements on the test program's diff --git a/indra/llmessage/tests/testrunner.py b/indra/llmessage/tests/testrunner.py index c25945067e..47c09ca245 100755 --- a/indra/llmessage/tests/testrunner.py +++ b/indra/llmessage/tests/testrunner.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """\ @file testrunner.py @author Nat Goodspeed @@ -41,7 +41,7 @@ VERBOSE = not re.match(r"(0|off|false|quiet)$", VERBOSE, re.IGNORECASE) if VERBOSE: def debug(fmt, *args): - print fmt % args + print(fmt % args) sys.stdout.flush() else: debug = lambda *args: None @@ -99,14 +99,14 @@ def freeport(portlist, expr): # error because we can't return meaningful values. We have no 'port', # therefore no 'expr(port)'. portiter = iter(portlist) - port = portiter.next() + port = next(portiter) while True: try: # If this value of port works, return as promised. value = expr(port) - except socket.error, err: + except socket.error as err: # Anything other than 'Address already in use', propagate if err.args[0] != errno.EADDRINUSE: raise @@ -117,9 +117,9 @@ def freeport(portlist, expr): type, value, tb = sys.exc_info() try: try: - port = portiter.next() + port = next(portiter) except StopIteration: - raise type, value, tb + raise type(value).with_traceback(tb) finally: # Clean up local traceback, see docs for sys.exc_info() del tb @@ -138,7 +138,7 @@ def freeport(portlist, expr): # If we've actually arrived at this point, portiter.next() delivered a # new port value. Loop back to pass that to expr(port). - except Exception, err: + except Exception as err: debug("*** freeport() raising %s: %s", err.__class__.__name__, err) raise @@ -227,13 +227,13 @@ def test_freeport(): def exc(exception_class, *args): try: yield - except exception_class, err: + except exception_class as err: for i, expected_arg in enumerate(args): assert expected_arg == err.args[i], \ "Raised %s, but args[%s] is %r instead of %r" % \ (err.__class__.__name__, i, err.args[i], expected_arg) - print "Caught expected exception %s(%s)" % \ - (err.__class__.__name__, ', '.join(repr(arg) for arg in err.args)) + print("Caught expected exception %s(%s)" % \ + (err.__class__.__name__, ', '.join(repr(arg) for arg in err.args))) else: assert False, "Failed to raise " + exception_class.__class__.__name__ @@ -270,18 +270,18 @@ def test_freeport(): # This is the magic exception that should prompt us to retry inuse = socket.error(errno.EADDRINUSE, 'Address already in use') # Get the iterator to our ports list so we can check later if we've used all - ports = iter(xrange(5)) + ports = iter(range(5)) with exc(socket.error, errno.EADDRINUSE): freeport(ports, lambda port: raiser(inuse)) # did we entirely exhaust 'ports'? with exc(StopIteration): - ports.next() + next(ports) - ports = iter(xrange(2)) + ports = iter(range(2)) # Any exception but EADDRINUSE should quit immediately with exc(SomeError): freeport(ports, lambda port: raiser(SomeError())) - assert_equals(ports.next(), 1) + assert_equals(next(ports), 1) # ----------- freeport() with platform-dependent socket stuff ------------ # This is what we should've had unit tests to begin with (see CHOP-661). @@ -290,14 +290,14 @@ def test_freeport(): sock.bind(('127.0.0.1', port)) return sock - bound0, port0 = freeport(xrange(7777, 7780), newbind) + bound0, port0 = freeport(range(7777, 7780), newbind) assert_equals(port0, 7777) - bound1, port1 = freeport(xrange(7777, 7780), newbind) + bound1, port1 = freeport(range(7777, 7780), newbind) assert_equals(port1, 7778) - bound2, port2 = freeport(xrange(7777, 7780), newbind) + bound2, port2 = freeport(range(7777, 7780), newbind) assert_equals(port2, 7779) with exc(socket.error, errno.EADDRINUSE): - bound3, port3 = freeport(xrange(7777, 7780), newbind) + bound3, port3 = freeport(range(7777, 7780), newbind) if __name__ == "__main__": test_freeport() |