Skip to content

Commit ec854eb

Browse files
committed
Skip AWS test if pymongo_auth_aws import fails
1 parent 673f8d1 commit ec854eb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/encryption_/tests.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from django.core.management import call_command
1111
from django.db import connections, models
1212
from django.test import TestCase, TransactionTestCase, modify_settings, override_settings
13-
from pymongo_auth_aws.auth import AwsCredential
1413

1514
from django_mongodb_backend.encryption import EqualityQuery
1615
from django_mongodb_backend.fields import EncryptedFieldMixin
@@ -187,11 +186,16 @@ def setUp(self):
187186
@classmethod
188187
def setUpClass(cls):
189188
super().setUpClass()
189+
try:
190+
from pymongo_auth_aws.auth import AwsCredential
191+
192+
cls.patch_aws = patch(
193+
"pymongocrypt.synchronous.credentials.aws_temp_credentials",
194+
return_value=AwsCredential(username="", password="", token=""),
195+
)
196+
except ImportError:
197+
cls.skipTest(cls, "pymongo_auth_aws not installed, skipping AWS credentials tests")
190198

191-
cls.patch_aws = patch(
192-
"pymongocrypt.synchronous.credentials.aws_temp_credentials",
193-
return_value=AwsCredential(username="", password="", token=""),
194-
)
195199
cls.patch_aws.start()
196200

197201
cls.patch_azure = patch(

0 commit comments

Comments
 (0)