summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLans Zhang <jia.zhang@windriver.com>2017-07-26 09:54:41 +0800
committerJeff Forcier <jeff@bitprophet.org>2021-11-28 20:24:17 -0500
commit15fa5b8d2a7750b2ead67580343bf96ff93f6840 (patch)
treef859192e249f7fcf1f145b82b6128d953e4d97d6
parentb79892d9e096851fc3f4d594afc509a745167863 (diff)
downloadparamiko-15fa5b8d2a7750b2ead67580343bf96ff93f6840.tar.gz
test_hostkeys: test SubDict.__delitem__()
SubDict.__delitem__() would trigger the KeyError exception if a key type to be deleted is not present. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
-rw-r--r--tests/test_hostkeys.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_hostkeys.py b/tests/test_hostkeys.py
index da47362c..e375687c 100644
--- a/tests/test_hostkeys.py
+++ b/tests/test_hostkeys.py
@@ -130,3 +130,20 @@ class HostKeysTest(unittest.TestCase):
pass # Good
else:
assert False, "Entry was not deleted from HostKeys on delitem!"
+
+ def test_entry_delitem(self):
+ hostdict = paramiko.HostKeys('hostfile.temp')
+ target = 'happy.example.com'
+ entry = hostdict[target]
+ key_type_list = [ key_type for key_type in entry ]
+ for key_type in key_type_list:
+ del entry[key_type]
+
+ # will KeyError if not present
+ for key_type in key_type_list:
+ try:
+ del entry[key_type]
+ except KeyError:
+ pass # Good
+ else:
+ assert False, "Key was not deleted from Entry on delitem!"