qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jr...@apache.org
Subject [qpid-proton] branch master updated: PROTON-2007: Correct example tests for the case where the system python differs from the harness python
Date Thu, 21 Feb 2019 16:00:47 GMT
This is an automated email from the ASF dual-hosted git repository.

jross pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/master by this push:
     new 25617ea  PROTON-2007: Correct example tests for the case where the system python
differs from the harness python
25617ea is described below

commit 25617ea41fffe6d31ae120979a7c1d482cd4f88f
Author: Justin Ross <jross@apache.org>
AuthorDate: Thu Feb 21 05:22:48 2019 -0800

    PROTON-2007: Correct example tests for the case where the system python differs from the
harness python
---
 python/examples/test_examples.py | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/python/examples/test_examples.py b/python/examples/test_examples.py
index aa6e2a5..048f839 100644
--- a/python/examples/test_examples.py
+++ b/python/examples/test_examples.py
@@ -17,16 +17,14 @@
 # under the License.
 #
 
+import re
 import sys
 import subprocess
 import time
 import unittest
 
-if sys.version_info[0] == 2:
-    _unicode_prefix = 'u'
-else:
-    _unicode_prefix = ''
-
+def remove_unicode_prefix(line):
+    return re.sub(r"u(['\"])", r"\1", line)
 
 class ExamplesTest(unittest.TestCase):
     def test_helloworld(self, example="helloworld.py"):
@@ -55,8 +53,8 @@ class ExamplesTest(unittest.TestCase):
                              universal_newlines=True)
         s.wait()
         r.wait()
-        actual = [l.strip() for l in r.stdout]
-        expected = ["{%s'sequence': int32(%i)}" % (_unicode_prefix, (i+1)) for i in range(100)]
+        actual = [remove_unicode_prefix(l.strip()) for l in r.stdout]
+        expected = ["{'sequence': int32(%i)}" % (i+1,) for i in range(100)]
         self.assertEqual(actual, expected)
 
     def test_client_server(self, client=['client.py'], server=['server.py'], sleep=0):
@@ -118,8 +116,8 @@ class ExamplesTest(unittest.TestCase):
         v = subprocess.Popen(['db_ctrl.py', 'list', './dst_db'], stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
                              universal_newlines=True)
         v.wait()
-        expected = ["(%i, %s'Message-%i')" % ((i+1), _unicode_prefix, (i+1)) for i in range(100)]
-        actual = [l.strip() for l in v.stdout]
+        expected = ["(%i, 'Message-%i')" % (i+1, i+1) for i in range(100)]
+        actual = [remove_unicode_prefix(l.strip()) for l in v.stdout]
         self.assertEqual(actual, expected)
 
     def test_tx_send_tx_recv(self):
@@ -134,8 +132,8 @@ class ExamplesTest(unittest.TestCase):
                              universal_newlines=True)
         s.wait()
         r.wait()
-        actual = [l.strip() for l in r.stdout]
-        expected = ["{%s'sequence': int32(%i)}" % (_unicode_prefix, (i+1)) for i in range(100)]
+        actual = [remove_unicode_prefix(l.strip()) for l in r.stdout]
+        expected = ["{'sequence': int32(%i)}" % (i+1,) for i in range(100)]
         self.assertEqual(actual, expected)
 
     def test_direct_send_simple_recv(self):
@@ -146,8 +144,8 @@ class ExamplesTest(unittest.TestCase):
                              universal_newlines=True)
         r.wait()
         s.wait()
-        actual = [l.strip() for l in r.stdout]
-        expected = ["{%s'sequence': int32(%i)}" % (_unicode_prefix, (i+1)) for i in range(100)]
+        actual = [remove_unicode_prefix(l.strip()) for l in r.stdout]
+        expected = ["{'sequence': int32(%i)}" % (i+1,) for i in range(100)]
         self.assertEqual(actual, expected)
 
     def test_selected_recv(self):


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


Mime
View raw message