summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMarius Gedminas <marius@gedmin.as>2016-02-05 08:43:50 +0200
committerJeff Forcier <jeff@bitprophet.org>2016-04-24 13:56:51 -0700
commit0411010d55755913fa7bd5b0a9c719c8548549f4 (patch)
treebb05b68c06f26f455e8604234676c285300dd802 /tests
parent858c167a6487e4a9d9cca3653b8e260f085dba02 (diff)
Improve NoValidConnectionsError formatting
Because "Unable to connect to port 22 on or X.X.X.X" looks seriously _weird_ with the blank space between "on" and "or".
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ssh_exception.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_ssh_exception.py b/tests/test_ssh_exception.py
index 2d1f899f..9c109de1 100644
--- a/tests/test_ssh_exception.py
+++ b/tests/test_ssh_exception.py
@@ -8,8 +8,23 @@ class NoValidConnectionsErrorTest (unittest.TestCase):
def test_pickling(self):
# Regression test for https://github.com/paramiko/paramiko/issues/617
- exc = NoValidConnectionsError({'ab': ''})
+ exc = NoValidConnectionsError({('127.0.0.1', '22'): Exception()})
new_exc = pickle.loads(pickle.dumps(exc))
self.assertEqual(type(exc), type(new_exc))
self.assertEqual(str(exc), str(new_exc))
self.assertEqual(exc.args, new_exc.args)
+
+ def test_error_message_for_single_host(self):
+ exc = NoValidConnectionsError({('127.0.0.1', '22'): Exception()})
+ self.assertIn("Unable to connect to port 22 on 127.0.0.1", str(exc))
+
+ def test_error_message_for_two_hosts(self):
+ exc = NoValidConnectionsError({('127.0.0.1', '22'): Exception(),
+ ('::1', '22'): Exception()})
+ self.assertIn("Unable to connect to port 22 on 127.0.0.1 or ::1", str(exc))
+
+ def test_error_message_for_multiple_hosts(self):
+ exc = NoValidConnectionsError({('127.0.0.1', '22'): Exception(),
+ ('::1', '22'): Exception(),
+ ('10.0.0.42', '22'): Exception()})
+ self.assertIn("Unable to connect to port 22 on 10.0.0.42, 127.0.0.1 or ::1", str(exc))