diff options
Diffstat (limited to 'tests/primitives')
| -rw-r--r-- | tests/primitives/test_hashes.py | 22 | 
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/primitives/test_hashes.py b/tests/primitives/test_hashes.py index 505f6c8a..7ddd1859 100644 --- a/tests/primitives/test_hashes.py +++ b/tests/primitives/test_hashes.py @@ -13,10 +13,14 @@  from __future__ import absolute_import, division, print_function +import pretend +  import pytest  import six +from cryptography.bindings import _default_api +  from cryptography.primitives import hashes  from .utils import generate_base_hash_test @@ -33,6 +37,24 @@ class TestBaseHash(object):          assert isinstance(m.hexdigest(), str) +class TestCopyHash(object): +    def test_copy_api_object(self): +        pretend_api = pretend.stub(copy_hash_context=lambda a: "copiedctx") +        pretend_ctx = pretend.stub() +        h = hashes.SHA1(api=pretend_api, ctx=pretend_ctx) +        assert h._api is pretend_api +        assert h.copy()._api is h._api + + +class TestDefaultAPISHA1(object): +    def test_default_api_creation(self): +        """ +        This test assumes the presence of SHA1 in the default API. +        """ +        h = hashes.SHA1() +        assert h._api is _default_api + +  class TestSHA1(object):      test_SHA1 = generate_base_hash_test(          hashes.SHA1,  | 
