[compute] Add unit test for keypair

keypair do not have unit test, this patch adds it.

Change-Id: Id702ccaad239b916340bb17014d1ede0a28aaec9
This commit is contained in:
jichenjc
2016-02-21 08:30:54 +08:00
parent b5b5fdd78a
commit 042e2b7d53
3 changed files with 318 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
"""Keypair action implementations"""
import io
import os
import six
import sys
@@ -47,7 +48,8 @@ class CreateKeypair(command.ShowOne):
public_key = parsed_args.public_key
if public_key:
try:
with open(os.path.expanduser(parsed_args.public_key)) as p:
with io.open(os.path.expanduser(parsed_args.public_key),
"rb") as p:
public_key = p.read()
except IOError as e:
msg = "Key file %s not found: %s"