This is an automated email from the ASF dual-hosted git repository.
kpvdr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-interop-test.git
The following commit(s) were added to refs/heads/main by this push:
new 266c23c Removed _compat.py for shim py2/3 compatibility, made all
shims py3 only.
266c23c is described below
commit 266c23c04aaaf406854694a528023ee263c4fdd2
Author: Kim van der Riet <[email protected]>
AuthorDate: Tue Sep 14 17:33:39 2021 -0400
Removed _compat.py for shim py2/3 compatibility, made all shims py3 only.
---
CMakeLists.txt | 16 ++---
setup.py | 12 ++--
shims/qpid-proton-python/src/_compat.py | 75 ----------------------
.../src/amqp_complex_types_test/Common.py | 11 ++--
.../src/amqp_complex_types_test/Receiver.py | 4 +-
.../src/amqp_complex_types_test/Sender.py | 2 +-
.../src/amqp_large_content_test/Receiver.py | 11 +---
.../src/amqp_large_content_test/Sender.py | 11 ++--
.../src/amqp_types_test/Receiver.py | 29 +++------
.../src/amqp_types_test/Sender.py | 21 +++---
.../src/jms_hdrs_props_test/Receiver.py | 23 ++-----
.../src/jms_hdrs_props_test/Sender.py | 21 +++---
.../src/jms_messages_test/Receiver.py | 21 ++----
.../src/jms_messages_test/Sender.py | 25 ++++----
.../amqp_complex_types_test_generator.py | 10 +--
src/python/qpid_interop_test/qit_xunit_log.py | 2 +-
16 files changed, 87 insertions(+), 207 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f520aa..4f38741 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,12 +60,12 @@ MACRO (find_python
endif ()
ENDMACRO ()
-find_python(python2 "PYTHON2_FOUND" "PYTHON2_VER" "PYTHON2_SITE_DIR_NAME")
+#find_python(python2 "PYTHON2_FOUND" "PYTHON2_VER" "PYTHON2_SITE_DIR_NAME")
# Python2 is required to run main QIT program
-if (NOT PYTHON2_FOUND)
- message(STATUS "ERROR: Python 2.x not found, but is required")
- set (ErrorFlag TRUE)
-endif ()
+#if (NOT PYTHON2_FOUND)
+# message(STATUS "ERROR: Python 2.x not found, but is required")
+# set (ErrorFlag TRUE)
+#endif ()
find_python(python3 "PYTHON3_FOUND" "PYTHON3_VER" "PYTHON3_SITE_DIR_NAME")
# Find Java 11
@@ -154,9 +154,9 @@ endif()
configure_file(config.sh.in config.sh @ONLY)
# Install files using python setup.py
-install(CODE "MESSAGE(STATUS \"Python 2 install dir:
${CMAKE_INSTALL_PREFIX}/lib/${PYTHON2_SITE_DIR_NAME}/site-packages/qpid_interop_test/\")")
-install(CODE "execute_process(COMMAND python2 setup.py install --prefix
${CMAKE_INSTALL_PREFIX}
- WORKING_DIRECTORY ../)")
+#install(CODE "MESSAGE(STATUS \"Python 2 install dir:
${CMAKE_INSTALL_PREFIX}/lib/${PYTHON2_SITE_DIR_NAME}/site-packages/qpid_interop_test/\")")
+#install(CODE "execute_process(COMMAND python2 setup.py install --prefix
${CMAKE_INSTALL_PREFIX}
+# WORKING_DIRECTORY ../)")
install(CODE "MESSAGE(STATUS \"Python 3 install dir:
${CMAKE_INSTALL_PREFIX}/lib/${PYTHON3_SITE_DIR_NAME}/site-packages/qpid_interop_test/\")")
install(CODE "execute_process(COMMAND python3 setup.py install --prefix
${CMAKE_INSTALL_PREFIX}
WORKING_DIRECTORY ../)")
diff --git a/setup.py b/setup.py
index e11bea9..b4e1308 100644
--- a/setup.py
+++ b/setup.py
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -31,13 +31,9 @@ setup(name='qpid-interop-test',
url='http://qpid.apache.org/',
packages=['qpid_interop_test'],
package_dir={'qpid_interop_test': 'src/python/qpid_interop_test'},
-
+
# Shims, installed into {INSTALL_PREFIX}/libexec/qpid_interop_test/shims/
- data_files=[ ('%s/qpid-proton-python' % SHIM_DIR,
- ['shims/qpid-proton-python/src/_compat.py',
- ]
- ),
- ('%s/qpid-proton-python/amqp_types_test' % SHIM_DIR,
+ data_files=[ ('%s/qpid-proton-python/amqp_types_test' % SHIM_DIR,
['shims/qpid-proton-python/src/amqp_types_test/Receiver.py',
'shims/qpid-proton-python/src/amqp_types_test/Sender.py',
]
diff --git a/shims/qpid-proton-python/src/_compat.py
b/shims/qpid-proton-python/src/_compat.py
deleted file mode 100644
index a0680c9..0000000
--- a/shims/qpid-proton-python/src/_compat.py
+++ /dev/null
@@ -1,75 +0,0 @@
-"""
-Python compatibility library that will help shims run under
-both Python 2.7 and Python 3.x
-"""
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-import string
-import sys
-import types
-
-IS_PY3 = sys.version_info[0] == 3
-
-if IS_PY3:
- def bytes_type():
- return bytes
- def decode_hex(s):
- return bytes.fromhex(s)
- def letters():
- return string.ascii_letters
- def long(i):
- return int(i)
- def long_type():
- return int
- def str2long(i, r):
- return int(i, r)
- def byte_char_ord(c):
- return c
- def unichr(i):
- return chr(i)
- def unicode(i):
- return str(i)
- def unicode_type():
- return str
-
-else:
- import __builtin__
-
- def bytes_type():
- return str
- def decode_hex(s):
- return s.decode('hex')
- def letters():
- return string.letters
- def long(i):
- return __builtin__.long(i)
- def long_type():
- return __builtin__.long
- def str2long(i, r):
- return __builtin__.long(i, r)
- def byte_char_ord(c):
- return __builtin__.ord(c)
- def unichr(i):
- return __builtin__.unichr(i)
- def unicode(i):
- return __builtin__.unicode(i)
- def unicode_type():
- return __builtin__.unicode
diff --git a/shims/qpid-proton-python/src/amqp_complex_types_test/Common.py
b/shims/qpid-proton-python/src/amqp_complex_types_test/Common.py
index e297f10..96a5aaf 100644
--- a/shims/qpid-proton-python/src/amqp_complex_types_test/Common.py
+++ b/shims/qpid-proton-python/src/amqp_complex_types_test/Common.py
@@ -30,7 +30,6 @@ import sys
import uuid
import proton
-import _compat
class AmqpComplexTypesTestShim(proton.handlers.MessagingHandler):
"""
@@ -76,7 +75,7 @@ class
AmqpComplexTypesTestShim(proton.handlers.MessagingHandler):
if isinstance(this_list[0], type(None)):
return this_list
elif self.amqp_subtype == '*':
- if isinstance(this_list[0], _compat.unicode_type()) and
this_list[0] == u'*':
+ if isinstance(this_list[0], str) and this_list[0] == u'*':
return this_list
else:
if self.amqp_subtype != '*':
@@ -103,7 +102,7 @@ class
AmqpComplexTypesTestShim(proton.handlers.MessagingHandler):
return this_map
elif self.amqp_subtype == '*':
for this_key in list(this_map.keys()): # can't use if u'*'
in list(this_map.keys()) - unicode errors
- if isinstance(this_key, _compat.unicode_type()) and
this_key == u'*':
+ if isinstance(this_key, str) and this_key == u'*':
return this_map
else:
key0 = list(this_map.keys())[0]
@@ -123,7 +122,7 @@ class
AmqpComplexTypesTestShim(proton.handlers.MessagingHandler):
'int': proton.int32,
'char': proton.char,
'ulong': proton.ulong,
- 'long': _compat.long_type(),
+ 'long': int,
'timestamp': proton.timestamp,
'float': proton.float32,
'double': float,
@@ -131,8 +130,8 @@ class
AmqpComplexTypesTestShim(proton.handlers.MessagingHandler):
'decimal64': proton.decimal64,
'decimal128': proton.decimal128,
'uuid': uuid.UUID,
- 'binary': _compat.bytes_type(),
- 'string': _compat.unicode_type(),
+ 'binary': bytes,
+ 'string': str,
'symbol': proton.symbol,
'array': proton.Array,
'list': list,
diff --git a/shims/qpid-proton-python/src/amqp_complex_types_test/Receiver.py
b/shims/qpid-proton-python/src/amqp_complex_types_test/Receiver.py
index fbeea3e..9a9498f 100644
--- a/shims/qpid-proton-python/src/amqp_complex_types_test/Receiver.py
+++ b/shims/qpid-proton-python/src/amqp_complex_types_test/Receiver.py
@@ -44,7 +44,7 @@ class
AmqpComplexTypesTestReceiver(amqp_complex_types_test.Common.AmqpComplexTyp
bodies of the exptected AMQP type. The values are then aggregated and
returned.
"""
def __init__(self, broker_url, queue_name, amqp_type, amqp_subtype):
- super(AmqpComplexTypesTestReceiver, self).__init__(broker_url,
queue_name, amqp_type, amqp_subtype, 'Receiver')
+ super().__init__(broker_url, queue_name, amqp_type, amqp_subtype,
'Receiver')
self.expected = 0
self.received = 0
@@ -137,7 +137,7 @@ class
AmqpComplexTypesTestReceiver(amqp_complex_types_test.Common.AmqpComplexTyp
#pylint: disable=unidiomatic-typecheck
if type(elt1) != type(elt2):
return False
- elif isinstance(elt1, proton.Array):
+ if isinstance(elt1, proton.Array):
if not AmqpComplexTypesTestReceiver.check_arrays_equal(elt1,
elt2):
return False
elif isinstance(elt1, list):
diff --git a/shims/qpid-proton-python/src/amqp_complex_types_test/Sender.py
b/shims/qpid-proton-python/src/amqp_complex_types_test/Sender.py
index 7640eac..3d70f63 100644
--- a/shims/qpid-proton-python/src/amqp_complex_types_test/Sender.py
+++ b/shims/qpid-proton-python/src/amqp_complex_types_test/Sender.py
@@ -42,7 +42,7 @@ class
AmqpComplexTypesTestSender(amqp_complex_types_test.Common.AmqpComplexTypes
AMQP type. There is no returned value.
"""
def __init__(self, broker_url, queue_name, amqp_type, amqp_subtype):
- super(AmqpComplexTypesTestSender, self).__init__(broker_url,
queue_name, amqp_type, amqp_subtype, 'Sender')
+ super().__init__(broker_url, queue_name, amqp_type, amqp_subtype,
'Sender')
self.sent = 0
self.confirmed = 0
self.total = 1
diff --git a/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py
b/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py
index b207e4c..dcd5d70 100755
--- a/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py
+++ b/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py
@@ -32,7 +32,6 @@ import traceback
import proton
import proton.handlers
import proton.reactor
-import _compat
class AmqpLargeContentTestReceiver(proton.handlers.MessagingHandler):
"""
@@ -40,7 +39,7 @@ class
AmqpLargeContentTestReceiver(proton.handlers.MessagingHandler):
...
"""
def __init__(self, broker_url, queue_name, amqp_type,
num_expected_messages_str):
- super(AmqpLargeContentTestReceiver, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.amqp_type = amqp_type
@@ -88,12 +87,8 @@ class
AmqpLargeContentTestReceiver(proton.handlers.MessagingHandler):
@staticmethod
def get_str_message_size(message):
"""Find the size of a bytes, unicode or symbol message in MB"""
- if _compat.IS_PY3:
- if isinstance(message, (bytes, str, proton.symbol)):
- return int(len(message) / 1024 / 1024) # in MB
- else:
- if isinstance(message, (bytes, unicode, proton.symbol)):
- return len(str(message)) / 1024 / 1024 # in MB
+ if isinstance(message, (bytes, str, proton.symbol)):
+ return int(len(message) / 1024 / 1024) # in MB
return None
@staticmethod
diff --git a/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py
b/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py
index 09367b6..ea08049 100755
--- a/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py
+++ b/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py
@@ -32,7 +32,6 @@ import traceback
import proton
import proton.handlers
import proton.reactor
-import _compat
class AmqpLargeContentTestSender(proton.handlers.MessagingHandler):
"""
@@ -40,7 +39,7 @@ class
AmqpLargeContentTestSender(proton.handlers.MessagingHandler):
...
"""
def __init__(self, broker_url, queue_name, amqp_type, test_value_list):
- super(AmqpLargeContentTestSender, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.amqp_type = amqp_type
@@ -83,7 +82,7 @@ class
AmqpLargeContentTestSender(proton.handlers.MessagingHandler):
if self.amqp_type == 'binary':
return
proton.Message(body=AmqpLargeContentTestSender.create_test_string(tot_size_bytes).encode('utf-8'))
if self.amqp_type == 'string':
- return
proton.Message(body=_compat.unicode(AmqpLargeContentTestSender.create_test_string(tot_size_bytes)))
+ return
proton.Message(body=str(AmqpLargeContentTestSender.create_test_string(tot_size_bytes)))
if self.amqp_type == 'symbol':
return
proton.Message(body=proton.symbol(AmqpLargeContentTestSender.create_test_string(tot_size_bytes)))
if self.amqp_type == 'list':
@@ -106,7 +105,7 @@ class
AmqpLargeContentTestSender(proton.handlers.MessagingHandler):
size_per_elt_bytes = int(tot_size_bytes / num_elts)
test_list = []
for _ in range(num_elts):
-
test_list.append(_compat.unicode(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes)))
+
test_list.append(str(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes)))
return test_list
@staticmethod
@@ -115,8 +114,8 @@ class
AmqpLargeContentTestSender(proton.handlers.MessagingHandler):
size_per_elt_bytes = int(tot_size_bytes / num_elts)
test_map = {}
for elt_no in range(num_elts):
- test_map[_compat.unicode('elt_%06d' % elt_no)] = \
-
_compat.unicode(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes))
+ test_map[str('elt_%06d' % elt_no)] = \
+
str(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes))
return test_map
def on_accepted(self, event):
diff --git a/shims/qpid-proton-python/src/amqp_types_test/Receiver.py
b/shims/qpid-proton-python/src/amqp_types_test/Receiver.py
index b4f50dd..cab746d 100755
--- a/shims/qpid-proton-python/src/amqp_types_test/Receiver.py
+++ b/shims/qpid-proton-python/src/amqp_types_test/Receiver.py
@@ -35,7 +35,6 @@ import uuid
import proton.handlers
import proton.reactor
-import _compat
class AmqpTypesTestReceiver(proton.handlers.MessagingHandler):
"""
@@ -44,7 +43,7 @@ class AmqpTypesTestReceiver(proton.handlers.MessagingHandler):
bodies of the exptected AMQP type. The values are then aggregated and
returned.
"""
def __init__(self, broker_url, queue_name, amqp_type,
num_expected_messages_str):
- super(AmqpTypesTestReceiver, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.received_value_list = []
@@ -116,9 +115,9 @@ class
AmqpTypesTestReceiver(proton.handlers.MessagingHandler):
if amqp_type == 'decimal64':
return '0x%016x' % amqp_value
if amqp_type == 'decimal128':
- return '0x' + ''.join(['%02x' % _compat.byte_char_ord(c) for c in
amqp_value]).strip()
+ return '0x' + ''.join(['%02x' % c for c in amqp_value]).strip()
if amqp_type == 'char':
- if ord(amqp_value) < 0x80 and amqp_value in string.digits +
_compat.letters() + string.punctuation + ' ':
+ if ord(amqp_value) < 0x80 and amqp_value in string.digits +
string.ascii_letters + string.punctuation + ' ':
return amqp_value
return hex(ord(amqp_value))
if amqp_type == 'timestamp':
@@ -177,21 +176,12 @@ class
AmqpTypesTestReceiver(proton.handlers.MessagingHandler):
if isinstance(amqp_value, proton.Array):
return "array"
# Native types come last so that parent classes will not be found
instead (issue using isinstance()
- if _compat.IS_PY3:
- if isinstance(amqp_value, int):
- return "long"
- if isinstance(amqp_value, bytes):
- return "binary"
- if isinstance(amqp_value, str):
- return "string"
- else:
- import __builtin__
- if isinstance(amqp_value, __builtin__.long):
- return "long"
- if isinstance(amqp_value, str):
- return "binary"
- if isinstance(amqp_value, unicode):
- return "string"
+ if isinstance(amqp_value, int):
+ return "long"
+ if isinstance(amqp_value, bytes):
+ return "binary"
+ if isinstance(amqp_value, str):
+ return "string"
if isinstance(amqp_value, float):
return "double"
if isinstance(amqp_value, list):
@@ -200,6 +190,7 @@ class
AmqpTypesTestReceiver(proton.handlers.MessagingHandler):
return "map"
print('receive: Unmapped AMQP type: %s:%s' % (type(amqp_value),
amqp_value))
+ return None
def on_transport_error(self, event):
print('Receiver: Broker not found at %s' % self.broker_url)
diff --git a/shims/qpid-proton-python/src/amqp_types_test/Sender.py
b/shims/qpid-proton-python/src/amqp_types_test/Sender.py
index 7e7f800..2c0eb67 100755
--- a/shims/qpid-proton-python/src/amqp_types_test/Sender.py
+++ b/shims/qpid-proton-python/src/amqp_types_test/Sender.py
@@ -34,7 +34,6 @@ import uuid
import proton.handlers
import proton.reactor
-import _compat
class AmqpTypesTestSender(proton.handlers.MessagingHandler):
"""
@@ -43,7 +42,7 @@ class AmqpTypesTestSender(proton.handlers.MessagingHandler):
AMQP type. There is no returned value.
"""
def __init__(self, broker_url, queue_name, amqp_type, test_value_list):
- super(AmqpTypesTestSender, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.amqp_type = amqp_type
@@ -85,7 +84,7 @@ class AmqpTypesTestSender(proton.handlers.MessagingHandler):
if amqp_type == 'null':
return None
if amqp_type == 'boolean':
- return True if test_value == 'True' else False
+ return test_value == 'True'
if amqp_type == 'ubyte':
return proton.ubyte(int(test_value, 16))
if amqp_type == 'ushort':
@@ -101,21 +100,21 @@ class
AmqpTypesTestSender(proton.handlers.MessagingHandler):
if amqp_type == 'int':
return proton.int32(int(test_value, 16))
if amqp_type == 'long':
- return _compat.str2long(test_value, 16)
+ return int(test_value, 16)
if amqp_type == 'float':
- return proton.float32(struct.unpack('!f',
_compat.decode_hex(test_value[2:]))[0])
+ return proton.float32(struct.unpack('!f',
bytes.fromhex(test_value[2:]))[0])
if amqp_type == 'double':
- return struct.unpack('!d', _compat.decode_hex(test_value[2:]))[0]
+ return struct.unpack('!d', bytes.fromhex(test_value[2:]))[0]
if amqp_type == 'decimal32':
return proton.decimal32(int(test_value[2:], 16))
if amqp_type == 'decimal64':
- return proton.decimal64(_compat.str2long(test_value[2:], 16))
+ return proton.decimal64(int(test_value[2:], 16))
if amqp_type == 'decimal128':
- return proton.decimal128(_compat.decode_hex(test_value[2:]))
+ return proton.decimal128(bytes.fromhex(test_value[2:]))
if amqp_type == 'char':
if len(test_value) == 1: # Format 'a'
return proton.char(test_value)
- return proton.char(_compat.unichr(int(test_value, 16)))
+ return proton.char(chr(int(test_value, 16)))
if amqp_type == 'timestamp':
return proton.timestamp(int(test_value, 16))
if amqp_type == 'uuid':
@@ -123,9 +122,9 @@ class AmqpTypesTestSender(proton.handlers.MessagingHandler):
if amqp_type == 'binary':
return base64.b64decode(test_value)
if amqp_type == 'binarystr':
- return _compat.unicode(test_value)
+ return str(test_value)
if amqp_type == 'string':
- return _compat.unicode(test_value)
+ return str(test_value)
if amqp_type == 'symbol':
return proton.symbol(test_value)
if amqp_type in ['array', 'list', 'map']:
diff --git a/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py
b/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py
index 3642149..8a68257 100755
--- a/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py
+++ b/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py
@@ -38,7 +38,6 @@ from qpid_interop_test.qit_jms_types import
QPID_JMS_TYPE_ANNOTATION_NAME
import proton
import proton.handlers
import proton.reactor
-import _compat
class JmsHdrsPropsTestReceiver(proton.handlers.MessagingHandler):
@@ -49,7 +48,7 @@ class
JmsHdrsPropsTestReceiver(proton.handlers.MessagingHandler):
the message are received on the command-line in JSON format when this
program is launched.
"""
def __init__(self, broker_url, queue_name, jms_msg_type,
test_parameters_list):
- super(JmsHdrsPropsTestReceiver, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.jms_msg_type = jms_msg_type
@@ -89,10 +88,7 @@ class
JmsHdrsPropsTestReceiver(proton.handlers.MessagingHandler):
return # ignore duplicate message
if self.received < self.expected:
if self.current_subtype is None:
- if _compat.IS_PY3:
- self.current_subtype = next(self.subtype_itr)
- else:
- self.current_subtype = self.subtype_itr.next()
+ self.current_subtype = next(self.subtype_itr)
self.current_subtype_msg_list = []
self.current_subtype_msg_list.append(self._handle_message(event.message))
self._process_jms_headers(event.message)
@@ -146,7 +142,6 @@ class
JmsHdrsPropsTestReceiver(proton.handlers.MessagingHandler):
if message.body is not None:
raise InteropTestError('_receive_jms_message: Invalid body for
type JMS_MESSAGE_TYPE: %s' %
str(message.body))
- return None
def _receive_jms_bytesmessage(self, message):
""""Receives a JMS bytes message"""
@@ -165,9 +160,7 @@ class
JmsHdrsPropsTestReceiver(proton.handlers.MessagingHandler):
return base64.b64encode(message.body).decode('utf-8')
if self.current_subtype == 'char':
if len(message.body) == 2: # format 'a' or '\xNN'
- if _compat.IS_PY3:
- return
base64.b64encode(bytes([message.body[1]])).decode('utf-8') # strip leading
'\x00' char
- return
base64.b64encode(bytes(message.body[1])).decode('utf-8') # strip leading '\x00'
char
+ return
base64.b64encode(bytes([message.body[1]])).decode('utf-8') # strip leading
'\x00' char
raise InteropTestError('Unexpected strring length for type char:
%d' % len(message.body))
if self.current_subtype == 'double':
return '0x%016x' % struct.unpack('!Q', message.body)[0]
@@ -206,9 +199,7 @@ class
JmsHdrsPropsTestReceiver(proton.handlers.MessagingHandler):
if self.current_subtype == 'bytes':
return base64.b64encode(value).decode('utf-8')
if self.current_subtype == 'char':
- if _compat.IS_PY3:
- return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
- return base64.b64encode(bytes(value)).decode('utf-8')
+ return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
if self.current_subtype == 'double':
return '0x%016x' % struct.unpack('!Q', struct.pack('!d', value))[0]
if self.current_subtype == 'float':
@@ -271,9 +262,7 @@ class
JmsHdrsPropsTestReceiver(proton.handlers.MessagingHandler):
if self.current_subtype == 'bytes':
return base64.b64encode(value).decode('utf-8')
if self.current_subtype == 'char':
- if _compat.IS_PY3:
- return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
- return base64.b64encode(bytes(value)).decode('utf-8')
+ return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
if self.current_subtype == 'double':
return '0x%016x' % struct.unpack('!Q', struct.pack('!d', value))[0]
if self.current_subtype == 'float':
@@ -421,4 +410,4 @@ except KeyboardInterrupt:
except Exception as exc:
print('jms-receiver-shim EXCEPTION:', exc)
print(traceback.format_exc())
- exit(1)
+ sys.exit(1)
diff --git a/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py
b/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py
index e19949d..92a02c3 100755
--- a/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py
+++ b/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py
@@ -38,7 +38,6 @@ import proton.reactor
#from qpid_interop_test.qit_common import QitTestTypeMap
from qpid_interop_test.qit_errors import InteropTestError
from qpid_interop_test.qit_jms_types import create_annotation
-import _compat
class JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
@@ -53,7 +52,7 @@ class
JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
with (or without) JMS headers and properties.
"""
def __init__(self, broker_url, queue_name, jms_msg_type,
test_parameters_list):
- super(JmsHdrsPropsTestSender, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.jms_msg_type = jms_msg_type
@@ -180,12 +179,12 @@ class
JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
elif test_value_type == 'char':
# JMS expects two-byte chars, ASCII chars can be prefixed with
'\x00'
body_bytes = b'\x00' + base64.b64decode(test_value)
- elif test_value_type == 'double' or test_value_type == 'float':
+ elif test_value_type in ('double', 'float'):
body_bytes = test_value[2:].decode('hex')
elif test_value_type == 'int':
body_bytes = struct.pack('!i', int(test_value, 16))
elif test_value_type == 'long':
- body_bytes = struct.pack('!q', _compat.str2long(test_value, 16))
+ body_bytes = struct.pack('!q', int(test_value, 16))
elif test_value_type == 'short':
body_bytes = struct.pack('!h', proton.short(test_value, 16))
elif test_value_type == 'string':
@@ -220,7 +219,7 @@ class
JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
elif test_value_type == 'int':
value = proton.int32(int(test_value, 16))
elif test_value_type == 'long':
- value = _compat.str2long(test_value, 16)
+ value = int(test_value, 16)
elif test_value_type == 'short':
value = proton.short(int(test_value, 16))
elif test_value_type == 'string':
@@ -277,7 +276,7 @@ class
JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
elif test_value_type == 'int':
body_list = [proton.int32(int(test_value, 16))]
elif test_value_type == 'long':
- body_list = [_compat.str2long(test_value, 16)]
+ body_list = [int(test_value, 16)]
elif test_value_type == 'short':
body_list = [proton.short(int(test_value, 16))]
elif test_value_type == 'string':
@@ -295,7 +294,7 @@ class
JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
def _create_jms_textmessage(self, test_value_text, hdr_kwargs,
hdr_annotations):
"""Create a JMS text message"""
return proton.Message(id=(self.sent+1),
- body=_compat.unicode(test_value_text),
+ body=str(test_value_text),
annotations=JmsHdrsPropsTestSender.merge_dicts(create_annotation('JMS_TEXTMESSAGE_TYPE'),
hdr_annotations),
**hdr_kwargs)
@@ -331,7 +330,7 @@ class
JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
elif value_type == 'topic':
hdr_kwargs['reply_to'] = value
hdr_annotations[proton.symbol(u'x-opt-jms-reply-to')] =
proton.byte(1)
- elif value_type == 'temp_queue' or value_type == 'temp_topic':
+ elif value_type in ('temp_queue', 'temp_topic'):
raise
InteropTestError('JmsSenderShim._get_jms_message_header_kwargs(): ' +
'JMS_REPLYTO_HEADER type
"temp_queue" or "temp_topic" not handled')
else:
@@ -356,14 +355,14 @@ class
JmsHdrsPropsTestSender(proton.handlers.MessagingHandler):
elif value_type == 'byte':
message.properties[property_name] = proton.byte(int(value, 16))
elif value_type == 'double':
- message.properties[property_name] = struct.unpack('!d',
_compat.decode_hex(value[2:]))[0]
+ message.properties[property_name] = struct.unpack('!d',
bytes.fromhex(value[2:]))[0]
elif value_type == 'float':
message.properties[property_name] =
proton.float32(struct.unpack('!f',
-
_compat.decode_hex(value[2:]))[0])
+
bytes.fromhex(value[2:]))[0])
elif value_type == 'int':
message.properties[property_name] = proton.int32(int(value,
16))
elif value_type == 'long':
- message.properties[property_name] = _compat.str2long(value, 16)
+ message.properties[property_name] = int(value, 16)
elif value_type == 'short':
message.properties[property_name] = proton.short(int(value,
16))
elif value_type == 'string':
diff --git a/shims/qpid-proton-python/src/jms_messages_test/Receiver.py
b/shims/qpid-proton-python/src/jms_messages_test/Receiver.py
index b457369..3bd2c8d 100755
--- a/shims/qpid-proton-python/src/jms_messages_test/Receiver.py
+++ b/shims/qpid-proton-python/src/jms_messages_test/Receiver.py
@@ -37,7 +37,6 @@ from qpid_interop_test.qit_jms_types import
QPID_JMS_TYPE_ANNOTATION_NAME
import proton
import proton.handlers
import proton.reactor
-import _compat
class JmsMessagesTestReceiver(proton.handlers.MessagingHandler):
"""
@@ -47,7 +46,7 @@ class
JmsMessagesTestReceiver(proton.handlers.MessagingHandler):
the message are received on the command-line in JSON format when this
program is launched.
"""
def __init__(self, broker_url, queue_name, jms_msg_type,
test_parameters_list):
- super(JmsMessagesTestReceiver, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.jms_msg_type = jms_msg_type
@@ -76,10 +75,7 @@ class
JmsMessagesTestReceiver(proton.handlers.MessagingHandler):
return # ignore duplicate message
if self.received < self.expected:
if self.current_subtype is None:
- if _compat.IS_PY3:
- self.current_subtype = next(self.subtype_itr)
- else:
- self.current_subtype = self.subtype_itr.next()
+ self.current_subtype = next(self.subtype_itr)
self.current_subtype_msg_list = []
self.current_subtype_msg_list.append(self._handle_message(event.message))
if len(self.current_subtype_msg_list) >=
self.expteced_msg_map[self.current_subtype]:
@@ -131,7 +127,6 @@ class
JmsMessagesTestReceiver(proton.handlers.MessagingHandler):
if message.body is not None:
raise InteropTestError('_receive_jms_message: Invalid body for
type JMS_MESSAGE_TYPE: %s' %
str(message.body))
- return None
def _receive_jms_bytesmessage(self, message):
"""Receives a JMS bytes message"""
@@ -150,9 +145,7 @@ class
JmsMessagesTestReceiver(proton.handlers.MessagingHandler):
return base64.b64encode(message.body).decode('utf-8')
if self.current_subtype == 'char':
if len(message.body) == 2: # format 'a' or '\xNN'
- if _compat.IS_PY3:
- return
base64.b64encode(bytes([message.body[1]])).decode('utf-8') # strip leading
'\x00' char
- return
base64.b64encode(bytes(message.body[1])).decode('utf-8') # strip leading '\x00'
char
+ return
base64.b64encode(bytes([message.body[1]])).decode('utf-8') # strip leading
'\x00' char
raise InteropTestError('Unexpected string length for type char:
%d' % len(message.body))
if self.current_subtype == 'double':
return '0x%016x' % struct.unpack('!Q', message.body)[0]
@@ -191,9 +184,7 @@ class
JmsMessagesTestReceiver(proton.handlers.MessagingHandler):
if self.current_subtype == 'bytes':
return base64.b64encode(value).decode('utf-8')
if self.current_subtype == 'char':
- if _compat.IS_PY3:
- return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
- return base64.b64encode(bytes(value)).decode('utf-8')
+ return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
if self.current_subtype == 'double':
return '0x%016x' % struct.unpack('!Q', struct.pack('!d', value))[0]
if self.current_subtype == 'float':
@@ -256,9 +247,7 @@ class
JmsMessagesTestReceiver(proton.handlers.MessagingHandler):
if self.current_subtype == 'bytes':
return base64.b64encode(value).decode('utf-8')
if self.current_subtype == 'char':
- if _compat.IS_PY3:
- return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
- return base64.b64encode(bytes(value)).decode('utf-8')
+ return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
if self.current_subtype == 'double':
return '0x%016x' % struct.unpack('!Q', struct.pack('!d', value))[0]
if self.current_subtype == 'float':
diff --git a/shims/qpid-proton-python/src/jms_messages_test/Sender.py
b/shims/qpid-proton-python/src/jms_messages_test/Sender.py
index 3707707..75415db 100755
--- a/shims/qpid-proton-python/src/jms_messages_test/Sender.py
+++ b/shims/qpid-proton-python/src/jms_messages_test/Sender.py
@@ -36,7 +36,6 @@ import proton.handlers
import proton.reactor
from qpid_interop_test.qit_errors import InteropTestError
from qpid_interop_test.qit_jms_types import create_annotation
-import _compat
class JmsMessagesTestSender(proton.handlers.MessagingHandler):
"""
@@ -50,7 +49,7 @@ class JmsMessagesTestSender(proton.handlers.MessagingHandler):
with (or without) JMS headers and properties.
"""
def __init__(self, broker_url, queue_name, jms_msg_type,
test_parameters_list):
- super(JmsMessagesTestSender, self).__init__()
+ super().__init__()
self.broker_url = broker_url
self.queue_name = queue_name
self.jms_msg_type = jms_msg_type
@@ -161,12 +160,12 @@ class
JmsMessagesTestSender(proton.handlers.MessagingHandler):
elif test_value_type == 'char':
# JMS expects two-byte chars, ASCII chars can be prefixed with
'\x00'
body_bytes = b'\x00' + base64.b64decode(test_value)
- elif test_value_type == 'double' or test_value_type == 'float':
- body_bytes = _compat.decode_hex(test_value[2:])
+ elif test_value_type in ('double', 'float'):
+ body_bytes = bytes.fromhex(test_value[2:])
elif test_value_type == 'int':
body_bytes = struct.pack('!i', int(test_value, 16))
elif test_value_type == 'long':
- body_bytes = struct.pack('!q', _compat.str2long(test_value, 16))
+ body_bytes = struct.pack('!q', int(test_value, 16))
elif test_value_type == 'short':
body_bytes = struct.pack('!h', proton.short(test_value, 16))
elif test_value_type == 'string':
@@ -194,13 +193,13 @@ class
JmsMessagesTestSender(proton.handlers.MessagingHandler):
elif test_value_type == 'char':
value = proton.char(base64.b64decode(test_value).decode('utf-8'))
elif test_value_type == 'double':
- value = struct.unpack('!d', _compat.decode_hex(test_value[2:]))[0]
+ value = struct.unpack('!d', bytes.fromhex(test_value[2:]))[0]
elif test_value_type == 'float':
- value = proton.float32(struct.unpack('!f',
_compat.decode_hex(test_value[2:]))[0])
+ value = proton.float32(struct.unpack('!f',
bytes.fromhex(test_value[2:]))[0])
elif test_value_type == 'int':
value = proton.int32(int(test_value, 16))
elif test_value_type == 'long':
- value = _compat.str2long(test_value, 16)
+ value = int(test_value, 16)
elif test_value_type == 'short':
value = proton.short(int(test_value, 16))
elif test_value_type == 'string':
@@ -234,7 +233,7 @@ class
JmsMessagesTestSender(proton.handlers.MessagingHandler):
if out_str_list[0] != java_class_str:
raise
InteropTestError('JmsMessagesTestSender._s_get_java_obj_binary(): ' \
'Call to JavaObjToBytes failed\n%s' %
out_str)
- return _compat.decode_hex(out_str_list[1])
+ return bytes.fromhex(out_str_list[1])
def _create_jms_streammessage(self, test_value_type, test_value):
"""Create a JMS stream message"""
@@ -247,13 +246,13 @@ class
JmsMessagesTestSender(proton.handlers.MessagingHandler):
elif test_value_type == 'char':
body_list =
[proton.char(base64.b64decode(test_value).decode('utf-8'))]
elif test_value_type == 'double':
- body_list = [struct.unpack('!d',
_compat.decode_hex(test_value[2:]))[0]]
+ body_list = [struct.unpack('!d', bytes.fromhex(test_value[2:]))[0]]
elif test_value_type == 'float':
- body_list = [proton.float32(struct.unpack('!f',
_compat.decode_hex(test_value[2:]))[0])]
+ body_list = [proton.float32(struct.unpack('!f',
bytes.fromhex(test_value[2:]))[0])]
elif test_value_type == 'int':
body_list = [proton.int32(int(test_value, 16))]
elif test_value_type == 'long':
- body_list = [_compat.str2long(test_value, 16)]
+ body_list = [int(test_value, 16)]
elif test_value_type == 'short':
body_list = [proton.short(int(test_value, 16))]
elif test_value_type == 'string':
@@ -270,7 +269,7 @@ class
JmsMessagesTestSender(proton.handlers.MessagingHandler):
def _create_jms_textmessage(self, test_value_text):
"""Create a JMS text message"""
return proton.Message(id=(self.sent+1),
- body=_compat.unicode(test_value_text),
+ body=str(test_value_text),
annotations=create_annotation('JMS_TEXTMESSAGE_TYPE'))
def on_transport_error(self, event):
diff --git a/src/python/qpid_interop_test/amqp_complex_types_test_generator.py
b/src/python/qpid_interop_test/amqp_complex_types_test_generator.py
index 9524310..1e46534 100755
--- a/src/python/qpid_interop_test/amqp_complex_types_test_generator.py
+++ b/src/python/qpid_interop_test/amqp_complex_types_test_generator.py
@@ -166,7 +166,7 @@ class PythonGenerator(Generator):
self.target_file.write('\n# *** THIS IS A GENERATED FILE, DO NOT EDIT
DIRECTLY ***\n')
self.target_file.write('# Generated by building qpid_interop_test\n')
self.target_file.write('# Generated: %s\n\n' % time.strftime('%Y-%m-%d
%H:%M:%S', time.gmtime()))
- self.target_file.write('import uuid\nimport proton\nimport
_compat\n\n')
+ self.target_file.write('import uuid\nimport proton\n\n')
self.target_file.write('TEST_DATA = {\n')
def write_code(self, amqp_test_type, json_data):
@@ -210,13 +210,13 @@ class PythonGenerator(Generator):
elif amqp_type == 'long':
if isinstance(value, str):
if (len(value) > 2 and value[:2] == '0x') or (len(value) > 3
and value[:3] == '-0x'):
- self.target_file.write('%s_compat.str2long(u\'%s\',
16)%s%s' %
+ self.target_file.write('%sint(u\'%s\', 16)%s%s' %
(indent_str, value, separator,
eol_char))
else:
- self.target_file.write('%s_compat.str2long(u\'%s\',
10)%s%s' %
+ self.target_file.write('%sint(u\'%s\', 10)%s%s' %
(indent_str, value, separator,
eol_char))
else:
- self.target_file.write('%s_compat.long(%s)%s%s' % (indent_str,
value, separator, eol_char))
+ self.target_file.write('%sint(%s)%s%s' % (indent_str, value,
separator, eol_char))
elif amqp_type == 'float':
if isinstance(value, str) and (value[-3:] == 'inf' or value[-3:]
== 'NaN'):
self.target_file.write('%sproton.float32(u\'%s\')%s%s' %
(indent_str, value, separator, eol_char))
@@ -242,7 +242,7 @@ class PythonGenerator(Generator):
if len(value) == 1: # single char
self.target_file.write('u\'%s\'' % value)
else:
- self.target_file.write('_compat.unichr(int(u\'%s\', 16))' %
value)
+ self.target_file.write('chr(int(u\'%s\', 16))' % value)
self.target_file.write(')%s%s' % (separator, eol_char))
elif amqp_type == 'timestamp':
self.target_file.write('%sproton.timestamp(%s)%s%s' % (indent_str,
value, separator, eol_char))
diff --git a/src/python/qpid_interop_test/qit_xunit_log.py
b/src/python/qpid_interop_test/qit_xunit_log.py
index c10c24e..c512fd3 100644
--- a/src/python/qpid_interop_test/qit_xunit_log.py
+++ b/src/python/qpid_interop_test/qit_xunit_log.py
@@ -71,7 +71,7 @@ class Xunit:
try:
return open(os.path.join(path, file_name), 'w')
except IOError as err:
- raise InteropTestError('Unable to open xUnit log file: %s' % err)
from err
+ raise InteropTestError('Unable to open xUnit log file: %s' % err)
@staticmethod
def _prettify(element):
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]