diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2014-11-12 13:49:03 -0800 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2014-11-12 13:53:12 -0800 |
commit | a08149d5f7aea1fcce55223a000ce9018df02961 (patch) | |
tree | a4b866ee293f40722e04069ad3fbb308a5aba9e8 | |
parent | 789527166be2921b7987ca2e921109ad26907db6 (diff) |
Failing test proving #429
-rw-r--r-- | tests/test_util.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/test_util.py b/tests/test_util.py index ecf8db72..0e7d0b2b 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -25,8 +25,8 @@ import errno import os from Crypto.Hash import SHA 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 @@ -344,3 +344,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) |