summaryrefslogtreecommitdiffhomepage
path: root/tests/test_util.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2014-11-12 13:56:08 -0800
committerJeff Forcier <jeff@bitprophet.org>2014-11-12 13:56:08 -0800
commite57e4ba1c44b05d0d4ce5f50be4b8676d9df79ed (patch)
tree76feb74b6f71a4141caa52f94145395d3e98095a /tests/test_util.py
parent5f28b9c5aed90394288fdc7249b5a527dc009f59 (diff)
parentee06fc8f634b424b026afde3b853f8c321b1919f (diff)
Merge branch '1.13' into 1.14
Diffstat (limited to 'tests/test_util.py')
-rw-r--r--tests/test_util.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/test_util.py b/tests/test_util.py
index 44fb8ab5..7889aa7a 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -26,8 +26,8 @@ import os
from hashlib import sha1
import paramiko.util
-from paramiko.util import lookup_ssh_host_config as host_config
-from paramiko.py3compat import StringIO, byte_ord
+from paramiko.util import lookup_ssh_host_config as host_config, safe_string
+from paramiko.py3compat import StringIO, byte_ord, b
from tests.util import ParamikoTest
@@ -339,3 +339,14 @@ IdentityFile something_%l_using_fqdn
config = paramiko.SSHConfig()
config.parse(config_file)
self.assertEqual(config.lookup("abcqwerty")["hostname"], "127.0.0.1")
+
+ def test_safe_string(self):
+ vanilla = b("vanilla")
+ has_bytes = b("has \7\3 bytes")
+ safe_vanilla = safe_string(vanilla)
+ safe_has_bytes = safe_string(has_bytes)
+ expected_bytes = b("has %07%03 bytes")
+ err = "{0!r} != {1!r}"
+ assert safe_vanilla == vanilla, err.format(safe_vanilla, vanilla)
+ assert safe_has_bytes == expected_bytes, \
+ err.format(safe_has_bytes, expected_bytes)