Skip to content

Commit

Permalink
tests: add basic pkey tests for equality and hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet authored and ploxiln committed Nov 29, 2021
1 parent 40daf20 commit 1cd926e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_pkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,25 @@ def test_certificates(self):
_support('test_rsa.key-cert.pub'),
)

def keys_loaded_twice(self):
for key_class, filename in [
(RSAKey, "test_rsa.key"),
(DSSKey, "test_dss.key"),
(ECDSAKey, "test_ecdsa_256.key"),
(Ed25519Key, "test_ed25519.key"),
]:
key1 = key_class.from_private_key_file(_support(filename))
key2 = key_class.from_private_key_file(_support(filename))
yield key1, key2

def test_keys_are_comparable(self):
for key1, key2 in self.keys_loaded_twice():
assert key1 == key2

def test_keys_are_hashable(self):
for key1, key2 in self.keys_loaded_twice():
assert hash(key1) == hash(key2)

def test_autodetect_ed25519(self):
key = load_private_key_file(_support("test_ed25519.key"))
self.assertIsInstance(key, Ed25519Key)
Expand Down

0 comments on commit 1cd926e

Please sign in to comment.