diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-03 09:58:45 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-03 09:58:45 -0700 |
commit | 81a5287984cd31080f7a5a1b249caf626ac8f6bf (patch) | |
tree | 9ebbf38b4779b64effec121a6d562c543b613e8b | |
parent | 548467c8d90a62d7e7647ae7b8d04cc6291d811e (diff) | |
download | cryptography-81a5287984cd31080f7a5a1b249caf626ac8f6bf.tar.gz cryptography-81a5287984cd31080f7a5a1b249caf626ac8f6bf.tar.bz2 cryptography-81a5287984cd31080f7a5a1b249caf626ac8f6bf.zip |
Use a None default so composition is easier
-rw-r--r-- | cryptography/primitives/block/base.py | 6 | ||||
-rw-r--r-- | tests/primitives/test_block.py | 7 | ||||
-rw-r--r-- | tox.ini | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/cryptography/primitives/block/base.py b/cryptography/primitives/block/base.py index 197807ea..b84ca9c4 100644 --- a/cryptography/primitives/block/base.py +++ b/cryptography/primitives/block/base.py @@ -24,8 +24,12 @@ class _Operation(Enum): class BlockCipher(object): - def __init__(self, cipher, mode, api=_default_api): + def __init__(self, cipher, mode, api=None): super(BlockCipher, self).__init__() + + if api is None: + api = _default_api + self.cipher = cipher self.mode = mode self._api = api diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py index 92fd31a3..774885fa 100644 --- a/tests/primitives/test_block.py +++ b/tests/primitives/test_block.py @@ -31,6 +31,13 @@ class TestBlockCipher(object): ) assert cipher.name == "AES-128-CBC" + def test_instantiate_without_api(self): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(b"0" * 32)), + modes.CBC(binascii.unhexlify(b"0" * 32)) + ) + assert cipher.name == "AES-128-CBC" + def test_use_after_finalize(self, api): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), @@ -8,7 +8,7 @@ deps = pretend commands = coverage run --source=cryptography/,tests/ -m pytest - coverage report + coverage report -m [testenv:docs] deps = sphinx |