瀏覽代碼

update paramiko tests

Filipp Frizzy 7 年之前
父節點
當前提交
3e4ba1b1c6
共有 1 個文件被更改,包括 4 次插入8 次删除
  1. 4 8
      dulwich/contrib/test_paramiko_vendor.py

+ 4 - 8
dulwich/contrib/test_paramiko_vendor.py

@@ -22,6 +22,7 @@
 
 from dulwich.tests import TestCase
 from dulwich.contrib.paramiko_vendor import ParamikoSSHVendor
+from paramiko.ssh_exception import NoValidConnectionsError
 
 
 CLIENT_KEY = """\
@@ -58,20 +59,15 @@ class ParamikoSSHVendorTests(TestCase):
 
     def test_run_command_password(self):
         vendor = ParamikoSSHVendor(allow_agent=False, look_for_keys=False)
-        try:
+        with self.assertRaises(NoValidConnectionsError):
             vendor.run_command(
                 '127.0.0.1', 'test_run_command_password',
                 username='user', port=2200, password='pass')
-        except Exception as e:
-            assert type(e).__name__ == 'NoValidConnectionsError'
-            assert e.__class__.__name__ == 'NoValidConnectionsError'
 
     def test_run_command_with_privkey(self):
         vendor = ParamikoSSHVendor(allow_agent=False, look_for_keys=False)
-        try:
+        with self.assertRaises(NoValidConnectionsError):
             vendor.run_command(
                 '127.0.0.1', 'test_run_command_with_privkey',
                 username='user', port=2200, pkey=CLIENT_KEY)
-        except Exception as e:
-            assert type(e).__name__ == 'NoValidConnectionsError'
-            assert e.__class__.__name__ == 'NoValidConnectionsError'
+