Skip to content

Commit 4362a50

Browse files
ansanpermattsb42-aws
authored andcommitted
Migrated "test/unit/test_aws_encryption_sdk.py" from unittest to pytest (#115)
* Migrate unit/test_defaults.py from unittest to pytest * Migrate unit/test_providers_base_master_key.py from unittest to pytest * Migrate unit/test_providers_base_master_key_provider.py from unitteest to pytest * Migrate unit/test_aws_encryption_sdk.py from unittest to pytest * Removed two unit tests not corresponding to this branch * Removed tests not corresponding to branch * Removed unused import six * Added yield and tearDown in apply_fixture function
1 parent 4857df9 commit 4362a50

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

test/unit/test_aws_encryption_sdk.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
"""Unit test suite for high-level functions in aws_encryption_sdk module"""
14-
import unittest
15-
1614
import pytest
17-
import six
1815
from mock import MagicMock, patch, sentinel
1916

2017
import aws_encryption_sdk
@@ -23,8 +20,9 @@
2320
pytestmark = [pytest.mark.unit, pytest.mark.local]
2421

2522

26-
class TestAwsEncryptionSdk(unittest.TestCase):
27-
def setUp(self):
23+
class TestAwsEncryptionSdk(object):
24+
@pytest.fixture(autouse=True)
25+
def apply_fixtures(self):
2826
# Set up StreamEncryptor patch
2927
self.mock_stream_encryptor_patcher = patch("aws_encryption_sdk.StreamEncryptor")
3028
self.mock_stream_encryptor = self.mock_stream_encryptor_patcher.start()
@@ -41,8 +39,8 @@ def setUp(self):
4139
self.mock_stream_decryptor_instance.header = sentinel.header
4240
self.mock_stream_decryptor.return_value = self.mock_stream_decryptor_instance
4341
self.mock_stream_decryptor_instance.__enter__.return_value = self.mock_stream_decryptor_instance
44-
45-
def tearDown(self):
42+
yield
43+
# Run tearDown
4644
self.mock_stream_encryptor_patcher.stop()
4745
self.mock_stream_decryptor_patcher.stop()
4846

@@ -77,5 +75,6 @@ def test_stream_decryptor_decrypt(self):
7775
assert test is self.mock_stream_decryptor_instance
7876

7977
def test_stream_unknown(self):
80-
with six.assertRaisesRegex(self, ValueError, "Unsupported mode: *"):
78+
with pytest.raises(ValueError) as excinfo:
8179
aws_encryption_sdk.stream(mode="ERROR", a=sentinel.a, b=sentinel.b, c=sentinel.b)
80+
excinfo.match("Unsupported mode: *")

0 commit comments

Comments
 (0)