PROTON-1854: [Python] Missing definition of unicode in python3
- Also added a test for message properties


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d9a74efc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d9a74efc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d9a74efc

Branch: refs/heads/go1
Commit: d9a74efce72e5d67d7d505b972d10dbf39951ba6
Parents: 81eac9e
Author: Andrew Stitcher <astitc...@apache.org>
Authored: Wed Jun 6 18:23:49 2018 +0100
Committer: Andrew Stitcher <astitc...@apache.org>
Committed: Wed Jun 6 18:23:49 2018 +0100

----------------------------------------------------------------------
 python/proton/_message.py            |  8 ++++++++
 tests/python/proton_tests/message.py | 10 ++++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d9a74efc/python/proton/_message.py
----------------------------------------------------------------------
diff --git a/python/proton/_message.py b/python/proton/_message.py
index 32a8c72..7b61940 100644
--- a/python/proton/_message.py
+++ b/python/proton/_message.py
@@ -46,6 +46,14 @@ from ._data import Data, ulong, symbol
 from ._endpoints import Link
 from ._exceptions import EXCEPTIONS, MessageException
 
+#
+# Hack to provide Python2 <---> Python3 compatibility
+try:
+    unicode()
+except NameError:
+    unicode = str
+
+
 PENDING = Constant("PENDING")
 ACCEPTED = Constant("ACCEPTED")
 REJECTED = Constant("REJECTED")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d9a74efc/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py 
b/tests/python/proton_tests/message.py
index 05a067c..1a2709c 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -106,6 +106,16 @@ class AccessorsTest(Test):
 
 class CodecTest(Test):
 
+  def testProperties(self):
+    self.msg.properties = {}
+    self.msg.properties['key'] = 'value'
+    data = self.msg.encode()
+
+    msg2 = Message()
+    msg2.decode(data)
+
+    assert msg2.properties['key'] == 'value', msg2.properties['key']
+
   def testRoundTrip(self):
     self.msg.id = "asdf"
     self.msg.correlation_id = uuid4()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to