cryptography
cryptography copied to clipboard
Add __eq__ to HashAlgorithm and padding instances
This PR:
- Adds
__eq__()to all subclasses of HashAlgorithm. - Adds
__eq__()to all padding classes.
My primary use case is testing. First, it's really un-pythonic to me (obviously very subjective, but it feels just not right to me) to write assert isinstance(cert.cert.signature_hash_algorithm, hashes.SHA256()), when I could write assert cert.cert.signature_hash_algorithm == hashes.SHA256(). But once you start comparing to other data structures, it gets even uglier:
def test_something() -> None:
...
assert isinstance(cert.signature_hash_algorithm, type(other.signature_hash_algorithm))
I think this just looks a lot better and readable:
def test_something() -> None:
...
assert cert.signature_hash_algorithm == other.signature_hash_algorithm