diff --git a/tests/test_core/test_decorator_calls.py b/tests/test_core/test_decorator_calls.py index a329f8bcd..05c23f1cb 100644 --- a/tests/test_core/test_decorator_calls.py +++ b/tests/test_core/test_decorator_calls.py @@ -1,5 +1,4 @@ import boto3 -import os import pytest import sure # noqa # pylint: disable=unused-import import unittest @@ -20,12 +19,12 @@ def test_basic_decorator(): @pytest.fixture -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - os.environ["AWS_ACCESS_KEY_ID"] = "testing" - os.environ["AWS_SECRET_ACCESS_KEY"] = "testing" - os.environ["AWS_SECURITY_TOKEN"] = "testing" - os.environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.mark.network diff --git a/tests/test_core/test_importorder.py b/tests/test_core/test_importorder.py index 9a00507d4..d4f3a3457 100644 --- a/tests/test_core/test_importorder.py +++ b/tests/test_core/test_importorder.py @@ -3,19 +3,18 @@ import pytest import sure # noqa # pylint: disable=unused-import from moto import mock_s3 from moto import settings -from os import environ from unittest import SkipTest @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): if settings.TEST_SERVER_MODE: raise SkipTest("No point in testing this in ServerMode.") """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") def test_mock_works_with_client_created_inside( diff --git a/tests/test_efs/test_access_point_tagging.py b/tests/test_efs/test_access_point_tagging.py index ab70296e9..4bc06d37c 100644 --- a/tests/test_efs/test_access_point_tagging.py +++ b/tests/test_efs/test_access_point_tagging.py @@ -1,5 +1,3 @@ -from os import environ - import boto3 import pytest @@ -7,12 +5,12 @@ from moto import mock_efs @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function") diff --git a/tests/test_efs/test_access_points.py b/tests/test_efs/test_access_points.py index 2523eff68..b3e45fc33 100644 --- a/tests/test_efs/test_access_points.py +++ b/tests/test_efs/test_access_points.py @@ -1,5 +1,3 @@ -from os import environ - import boto3 import pytest from botocore.exceptions import ClientError @@ -9,12 +7,12 @@ from moto.core import ACCOUNT_ID @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function") diff --git a/tests/test_efs/test_file_system.py b/tests/test_efs/test_file_system.py index d6f04cb2f..25caeb03e 100644 --- a/tests/test_efs/test_file_system.py +++ b/tests/test_efs/test_file_system.py @@ -1,5 +1,4 @@ import re -from os import environ import boto3 import pytest @@ -32,12 +31,12 @@ SAMPLE_2_PARAMS = { @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function") diff --git a/tests/test_efs/test_filesystem_tagging.py b/tests/test_efs/test_filesystem_tagging.py index a0d7dae9b..a01135346 100644 --- a/tests/test_efs/test_filesystem_tagging.py +++ b/tests/test_efs/test_filesystem_tagging.py @@ -1,5 +1,3 @@ -from os import environ - import boto3 import pytest @@ -7,12 +5,12 @@ from moto import mock_efs @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function") diff --git a/tests/test_efs/test_lifecycle_config.py b/tests/test_efs/test_lifecycle_config.py index fbabe2162..c03c91534 100644 --- a/tests/test_efs/test_lifecycle_config.py +++ b/tests/test_efs/test_lifecycle_config.py @@ -1,5 +1,3 @@ -from os import environ - import boto3 import pytest from botocore.exceptions import ClientError @@ -8,12 +6,12 @@ from moto import mock_efs @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function") diff --git a/tests/test_efs/test_mount_target.py b/tests/test_efs/test_mount_target.py index 6e2e31632..7b4a1d2e5 100644 --- a/tests/test_efs/test_mount_target.py +++ b/tests/test_efs/test_mount_target.py @@ -1,6 +1,5 @@ import re import sys -from os import environ from ipaddress import IPv4Network import boto3 @@ -38,12 +37,12 @@ else: @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function") diff --git a/tests/test_efs/test_mount_target_security_groups.py b/tests/test_efs/test_mount_target_security_groups.py index 7f6fb1798..05fc2ee2f 100644 --- a/tests/test_efs/test_mount_target_security_groups.py +++ b/tests/test_efs/test_mount_target_security_groups.py @@ -1,5 +1,3 @@ -from os import environ - import boto3 import pytest from botocore.exceptions import ClientError @@ -8,12 +6,12 @@ from moto import mock_ec2, mock_efs @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function") diff --git a/tests/test_efs/test_server.py b/tests/test_efs/test_server.py index 2670a3f5d..207280d82 100644 --- a/tests/test_efs/test_server.py +++ b/tests/test_efs/test_server.py @@ -1,6 +1,4 @@ import re -from os import environ - import pytest from moto import mock_efs, mock_ec2 @@ -12,12 +10,12 @@ MOUNT_TARGETS = "/2015-02-01/mount-targets" @pytest.fixture(scope="function") -def aws_credentials(): +def aws_credentials(monkeypatch): """Mocked AWS Credentials for moto.""" - environ["AWS_ACCESS_KEY_ID"] = "testing" - environ["AWS_SESSION_TOKEN"] = "testing" - environ["AWS_SECRET_ACCESS_KEY"] = "testing" - environ["AWS_SECURITY_TOKEN"] = "testing" + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.setenv("AWS_SECURITY_TOKEN", "testing") + monkeypatch.setenv("AWS_SESSION_TOKEN", "testing") @pytest.fixture(scope="function")