This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git


The following commit(s) were added to refs/heads/trunk by this push:
     new df060de6e test: fix test_ssh_client on big-endian architectures
     new dd252cccc Merge pull request #1693 from ogayot/fix-big-endian-test
df060de6e is described below

commit df060de6ea325cba2b6411780728705252543bc3
Author: Olivier Gayot <olivier.ga...@canonical.com>
AuthorDate: Thu May 12 11:23:15 2022 +0200

    test: fix test_ssh_client on big-endian architectures
    
    The tests test_consume_*_chunk_contains_no_utf8_character are meant to
    ensure support for non-UTF-8 characters. To do so, we use UTF-8
    characters and compare their binary representation after being fed to
    paramiko.
    
    Unfortunately, UTF-32 is affected by endianness, resulting in failed
    tests on big-endian architectures.
    
    Fixed by checking the endianness and comparing the UTF-32 characters to
    their respective binary representation.
---
 libcloud/test/compute/test_ssh_client.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libcloud/test/compute/test_ssh_client.py 
b/libcloud/test/compute/test_ssh_client.py
index 04c40406c..d9d547cad 100644
--- a/libcloud/test/compute/test_ssh_client.py
+++ b/libcloud/test/compute/test_ssh_client.py
@@ -626,7 +626,10 @@ class ParamikoSSHClientTests(LibcloudTestCase):
         chan.recv.side_effect = ["🤦".encode("utf-32"), "a", "b"]
 
         stdout = client._consume_stdout(chan).getvalue()
-        self.assertEqual("\x00\x00&\x01\x00ab", stdout)
+        if sys.byteorder == "little":
+            self.assertEqual("\x00\x00&\x01\x00ab", stdout)
+        else:
+            self.assertEqual("\x00\x00\x00\x01&ab", stdout)
         self.assertEqual(len(stdout), 7)
 
     def test_consume_stderr_chunk_contains_non_utf8_character(self):
@@ -639,7 +642,10 @@ class ParamikoSSHClientTests(LibcloudTestCase):
         chan.recv_stderr.side_effect = ["🤦".encode("utf-32"), "a", "b"]
 
         stderr = client._consume_stderr(chan).getvalue()
-        self.assertEqual("\x00\x00&\x01\x00ab", stderr)
+        if sys.byteorder == "little":
+            self.assertEqual("\x00\x00&\x01\x00ab", stderr)
+        else:
+            self.assertEqual("\x00\x00\x00\x01&ab", stderr)
         self.assertEqual(len(stderr), 7)
 
     def test_keep_alive_and_compression(self):

Reply via email to