py26 compat: with x, y -> with x: with y

This commit is contained in:
Jakub Warmuz
2015-03-21 20:54:02 +00:00
parent 71d8999e7c
commit 006fcbbf46
+16 -12
View File
@@ -205,29 +205,33 @@ class CLITest(unittest.TestCase):
def test_unverified(self): def test_unverified(self):
from letsencrypt.acme.jose.jws import CLI from letsencrypt.acme.jose.jws import CLI
with mock.patch('sys.stdin') as sin, mock.patch('sys.stdout'): with mock.patch('sys.stdin') as sin:
sin.read.return_value = '{"payload": "foo", "signature": "xxx"}' sin.read.return_value = '{"payload": "foo", "signature": "xxx"}'
self.assertEqual(-1, CLI.run(['verify'])) with mock.patch('sys.stdout'):
self.assertEqual(-1, CLI.run(['verify']))
def test_json(self): def test_json(self):
from letsencrypt.acme.jose.jws import CLI from letsencrypt.acme.jose.jws import CLI
with mock.patch('sys.stdin') as sin, mock.patch('sys.stdout') as sout: with mock.patch('sys.stdin') as sin:
sin.read.return_value = 'foo' sin.read.return_value = 'foo'
CLI.run(['sign', '-k', self.key_path, '-a', 'RS256', with mock.patch('sys.stdout') as sout:
'-p', 'jwk']) CLI.run(['sign', '-k', self.key_path, '-a', 'RS256',
sin.read.return_value = sout.write.mock_calls[0][1][0] '-p', 'jwk'])
self.assertEqual(0, CLI.run(['verify'])) sin.read.return_value = sout.write.mock_calls[0][1][0]
self.assertEqual(0, CLI.run(['verify']))
def test_compact(self): def test_compact(self):
from letsencrypt.acme.jose.jws import CLI from letsencrypt.acme.jose.jws import CLI
with mock.patch('sys.stdin') as sin, mock.patch('sys.stdout') as sout: with mock.patch('sys.stdin') as sin:
sin.read.return_value = 'foo' sin.read.return_value = 'foo'
CLI.run(['--compact', 'sign', '-k', self.key_path]) with mock.patch('sys.stdout') as sout:
sin.read.return_value = sout.write.mock_calls[0][1][0] CLI.run(['--compact', 'sign', '-k', self.key_path])
self.assertEqual(0, CLI.run([ sin.read.return_value = sout.write.mock_calls[0][1][0]
'--compact', 'verify', '--kty', 'RSA', '-k', self.key_path])) self.assertEqual(0, CLI.run([
'--compact', 'verify', '--kty', 'RSA',
'-k', self.key_path]))
if __name__ == '__main__': if __name__ == '__main__':