summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2017-10-10 15:54:02 -0700
committerJeff Forcier <jeff@bitprophet.org>2017-10-10 15:54:02 -0700
commitbac31540cf83b718324928e69e1bf43ff17cb590 (patch)
treea794cd263c586db6375cad0391400174a4cf5be9
parent2ffbd2f94c7c946d8f480191e086bc503cf2e1b7 (diff)
downloadparamiko-bac31540cf83b718324928e69e1bf43ff17cb590.tar.gz
Update still-failing client test to use contextmanager assertRaises style
-rw-r--r--tests/test_client.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/test_client.py b/tests/test_client.py
index 1068a8ad..45be5926 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -578,19 +578,17 @@ class SSHClientTest (unittest.TestCase):
self.assertEqual(target_env, getattr(schan, 'env', {}))
schan.close()
- # Cannot use assertRaises in context manager mode as it is not supported
- # in Python 2.6.
- try:
+ with self.assertRaises(SSHException) as manager:
# Verify that a rejection by the server can be detected
self.tc.exec_command('yes', environment={b'INVALID_ENV': b''})
- except SSHException as e:
- self.assertTrue('INVALID_ENV' in str(e),
- 'Expected variable name in error message')
- self.assertTrue(isinstance(e.args[1], SSHException),
- 'Expected original SSHException in exception')
- else:
- self.fail('SSHException was not thrown.')
-
+ self.assertTrue(
+ 'INVALID_ENV' in str(manager.exception),
+ 'Expected variable name in error message'
+ )
+ self.assertTrue(
+ isinstance(manager.exception.args[1], SSHException),
+ 'Expected original SSHException in exception'
+ )
def test_missing_key_policy_accepts_classes_or_instances(self):
"""