tests: clean up old-style SSH exception catch

pull/607/head
David Wilson 6 years ago
parent 4524f03a48
commit baafc746fe

@ -91,26 +91,20 @@ class SshTest(testlib.DockerMixin, testlib.TestCase):
self.assertEquals(name, sudo.name) self.assertEquals(name, sudo.name)
def test_password_required(self): def test_password_required(self):
try: e = self.assertRaises(mitogen.ssh.PasswordError,
context = self.docker_ssh( lambda: self.docker_ssh(
username='mitogen__has_sudo', username='mitogen__has_sudo',
) )
assert 0, 'exception not thrown' )
except mitogen.ssh.PasswordError:
e = sys.exc_info()[1]
self.assertEqual(e.args[0], mitogen.ssh.password_required_msg) self.assertEqual(e.args[0], mitogen.ssh.password_required_msg)
def test_password_incorrect(self): def test_password_incorrect(self):
try: e = self.assertRaises(mitogen.ssh.PasswordError,
context = self.docker_ssh( lambda: self.docker_ssh(
username='mitogen__has_sudo', username='mitogen__has_sudo',
password='badpw', password='badpw',
) )
assert 0, 'exception not thrown' )
except mitogen.ssh.PasswordError:
e = sys.exc_info()[1]
self.assertEqual(e.args[0], mitogen.ssh.password_incorrect_msg) self.assertEqual(e.args[0], mitogen.ssh.password_incorrect_msg)
def test_password_specified(self): def test_password_specified(self):
@ -125,14 +119,11 @@ class SshTest(testlib.DockerMixin, testlib.TestCase):
) )
def test_pubkey_required(self): def test_pubkey_required(self):
try: e = self.assertRaises(mitogen.ssh.PasswordError,
context = self.docker_ssh( lambda: self.docker_ssh(
username='mitogen__has_sudo_pubkey', username='mitogen__has_sudo_pubkey',
) )
assert 0, 'exception not thrown' )
except mitogen.ssh.PasswordError:
e = sys.exc_info()[1]
self.assertEqual(e.args[0], mitogen.ssh.password_required_msg) self.assertEqual(e.args[0], mitogen.ssh.password_required_msg)
def test_pubkey_specified(self): def test_pubkey_specified(self):

Loading…
Cancel
Save