Skip to content

Migrate "test/unit/test_serialize.py" from unittest to pytest #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 17, 2018
11 changes: 5 additions & 6 deletions test/unit/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Unit test suite for aws_encryption_sdk.internal.formatting.serialize"""
import unittest

import pytest
from mock import MagicMock, patch, sentinel

Expand Down Expand Up @@ -51,8 +49,9 @@ def test_serialize_frame_invalid_sequence_number(sequence_number, error_message)
excinfo.match(error_message)


class TestSerialize(unittest.TestCase):
def setUp(self):
class TestSerialize(object):
@pytest.fixture(autouse=True)
def apply_fixtures(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #127 : need to run teardown actions.

self.mock_algorithm = MagicMock()
self.mock_algorithm.encryption_algorithm.block_size = VALUES["block_size"]
self.mock_algorithm.algorithm_id = VALUES["algorithm_id"]
Expand Down Expand Up @@ -84,8 +83,8 @@ def setUp(self):
self.mock_signer = MagicMock()
self.mock_signer.update.return_value = None
self.mock_signer.finalize.return_value = VALUES["signature"]

def tearDown(self):
yield
# Run tearDown
self.mock_serialize_acc_patcher.stop()
self.mock_encrypt_patcher.stop()
self.mock_valid_frame_length_patcher.stop()
Expand Down