diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-20 15:05:27 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-20 15:05:27 -0600 |
commit | 81a68fc96d0845f5ee812665405276a935d05a79 (patch) | |
tree | 0478a737c0db71df5bee8f1b02d2a89713590867 /tests/test_utils.py | |
parent | 74169660e47b760f82c0653b4210b3bc5d3bf46b (diff) | |
parent | 78456c71627d9234a4668ce2fb36e12525cae6b1 (diff) | |
download | cryptography-81a68fc96d0845f5ee812665405276a935d05a79.tar.gz cryptography-81a68fc96d0845f5ee812665405276a935d05a79.tar.bz2 cryptography-81a68fc96d0845f5ee812665405276a935d05a79.zip |
Merge branch 'master' into urandom-engine
* master: (58 commits)
Moar backtick.
Add to changelog.
move some dashes around :)
experiment to disable duplicate cc test runs on osx and speed up travis
Remove register_cipher_adapter from the interface and the documentation.
expand tox backend example
On OS X at build time compile the CC bindings
remove an extraneous linefeed
reformat bindings and remove GCM for the moment
add cipher bindings for CommonCrypto
doc updates
hmac support for commoncrypto
added versionadded
changelog to note addition of commoncrypto backend with hash support
fix docs
doc updates
update docs for name attribute
fix copy mistake in docs
increase indent and note the value of the attribute in the docs
move HashMethods to top level
...
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r-- | tests/test_utils.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index e3e53d63..f852f3ab 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -21,7 +21,7 @@ import pytest from .utils import ( load_nist_vectors, load_vectors_from_file, load_cryptrec_vectors, load_openssl_vectors, load_hash_vectors, check_for_iface, - check_backend_support + check_backend_support, select_backends ) @@ -29,6 +29,48 @@ class FakeInterface(object): pass +def test_select_one_backend(): + b1 = pretend.stub(name="b1") + b2 = pretend.stub(name="b2") + b3 = pretend.stub(name="b3") + backends = [b1, b2, b3] + name = "b2" + selected_backends = select_backends(name, backends) + assert len(selected_backends) == 1 + assert selected_backends[0] == b2 + + +def test_select_no_backend(): + b1 = pretend.stub(name="b1") + b2 = pretend.stub(name="b2") + b3 = pretend.stub(name="b3") + backends = [b1, b2, b3] + name = "back!" + with pytest.raises(ValueError): + select_backends(name, backends) + + +def test_select_backends_none(): + b1 = pretend.stub(name="b1") + b2 = pretend.stub(name="b2") + b3 = pretend.stub(name="b3") + backends = [b1, b2, b3] + name = None + selected_backends = select_backends(name, backends) + assert len(selected_backends) == 3 + + +def test_select_two_backends(): + b1 = pretend.stub(name="b1") + b2 = pretend.stub(name="b2") + b3 = pretend.stub(name="b3") + backends = [b1, b2, b3] + name = "b2 ,b1 " + selected_backends = select_backends(name, backends) + assert len(selected_backends) == 2 + assert selected_backends == [b1, b2] + + def test_check_for_iface(): item = pretend.stub(keywords=["fake_name"], funcargs={"backend": True}) with pytest.raises(pytest.skip.Exception) as exc_info: |