summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--paramiko/ssh_exception.py3
-rwxr-xr-xtest.py4
-rw-r--r--tests/test_ssh_exception.py15
3 files changed, 21 insertions, 1 deletions
diff --git a/paramiko/ssh_exception.py b/paramiko/ssh_exception.py
index 016a411e..b61000ae 100644
--- a/paramiko/ssh_exception.py
+++ b/paramiko/ssh_exception.py
@@ -173,3 +173,6 @@ class NoValidConnectionsError(socket.error):
msg.format(addrs[0][1], body, tail)
)
self.errors = errors
+
+ def __reduce__(self):
+ return (NoValidConnectionsError, (self.errors, ))
diff --git a/test.py b/test.py
index 37fc5a6f..a1f13d85 100755
--- a/test.py
+++ b/test.py
@@ -43,8 +43,9 @@ from tests.test_kex import KexTest
from tests.test_packetizer import PacketizerTest
from tests.test_auth import AuthTest
from tests.test_transport import TransportTest
+from tests.test_ssh_exception import NoValidConnectionsErrorTest
from tests.test_client import SSHClientTest
-from test_client import SSHClientTest
+from test_client import SSHClientTest # XXX why shadow the above import?
from test_gssapi import GSSAPITest
from test_ssh_gss import GSSAuthTest
from test_kex_gss import GSSKexTest
@@ -156,6 +157,7 @@ def main():
if options.use_transport:
suite.addTest(unittest.makeSuite(AuthTest))
suite.addTest(unittest.makeSuite(TransportTest))
+ suite.addTest(unittest.makeSuite(NoValidConnectionsErrorTest))
suite.addTest(unittest.makeSuite(SSHClientTest))
if options.use_sftp:
suite.addTest(unittest.makeSuite(SFTPTest))
diff --git a/tests/test_ssh_exception.py b/tests/test_ssh_exception.py
new file mode 100644
index 00000000..2d1f899f
--- /dev/null
+++ b/tests/test_ssh_exception.py
@@ -0,0 +1,15 @@
+import pickle
+import unittest
+
+from paramiko.ssh_exception import NoValidConnectionsError
+
+
+class NoValidConnectionsErrorTest (unittest.TestCase):
+
+ def test_pickling(self):
+ # Regression test for https://github.com/paramiko/paramiko/issues/617
+ exc = NoValidConnectionsError({'ab': ''})
+ 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)