Skip to content

Commit cba6995

Browse files
author
Andres Sanchez
committed
Migrated unit/test/_providers_kms_master_key_provider.py from unittest to pytest
1 parent a070cb6 commit cba6995

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

test/unit/test_providers_kms_master_key_provider.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
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 from aws_encryption_sdk.key_providers.kms.KMSMasterKeyProvider"""
14-
import unittest
15-
1614
import botocore.client
1715
import pytest
1816
import six
@@ -32,8 +30,9 @@ def test_init_with_regionless_key_ids_and_region_names():
3230
assert provider.master_key("alias/key_1").config.client.meta.region_name == region_names[0]
3331

3432

35-
class TestKMSMasterKeyProvider(unittest.TestCase):
36-
def setUp(self):
33+
class TestKMSMasterKeyProvider(object):
34+
@pytest.fixture(autouse=True)
35+
def apply_fixtures(self):
3736
self.mock_botocore_session_patcher = patch("aws_encryption_sdk.key_providers.kms.botocore.session.Session")
3837
self.mock_botocore_session = self.mock_botocore_session_patcher.start()
3938
self.mock_boto3_session_patcher = patch("aws_encryption_sdk.key_providers.kms.boto3.session.Session")
@@ -130,10 +129,9 @@ def test_client_no_region_name_with_default(self, mock_add_client):
130129

131130
def test_client_no_region_name_without_default(self):
132131
test = KMSMasterKeyProvider()
133-
with six.assertRaisesRegex(
134-
self, UnknownRegionError, "No default region found and no region determinable from key id: *"
135-
):
132+
with pytest.raises(UnknownRegionError) as excinfo:
136133
test._client("")
134+
excinfo.match("No default region found and no region determinable from key id: *")
137135

138136
@patch("aws_encryption_sdk.key_providers.kms.KMSMasterKeyProvider._client")
139137
def test_new_master_key(self, mock_client):

0 commit comments

Comments
 (0)