From ceb16b00a7dcfe36a9255c30aa4c7ab17317f3d6 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sun, 2 Feb 2020 12:45:57 +0000 Subject: [PATCH] S3 LocationConstraint test can only be run in non-ServerMode --- tests/test_s3/test_s3.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py index 33b4299a6..56cbe547b 100644 --- a/tests/test_s3/test_s3.py +++ b/tests/test_s3/test_s3.py @@ -1118,17 +1118,22 @@ def test_bucket_location_nondefault(): ) -@mock_s3 -def test_s3_location_should_error_outside_useast1(): - s3 = boto3.client("s3", region_name="eu-west-1") +# Test uses current Region to determine whether to throw an error +# Region is retrieved based on current URL +# URL will always be localhost in Server Mode, so can't run it there +if not settings.TEST_SERVER_MODE: - bucket_name = "asdfasdfsdfdsfasda" + @mock_s3 + def test_s3_location_should_error_outside_useast1(): + s3 = boto3.client("s3", region_name="eu-west-1") - with assert_raises(ClientError) as e: - s3.create_bucket(Bucket=bucket_name) - e.exception.response["Error"]["Message"].should.equal( - "The unspecified location constraint is incompatible for the region specific endpoint this request was sent to." - ) + bucket_name = "asdfasdfsdfdsfasda" + + with assert_raises(ClientError) as e: + s3.create_bucket(Bucket=bucket_name) + e.exception.response["Error"]["Message"].should.equal( + "The unspecified location constraint is incompatible for the region specific endpoint this request was sent to." + ) @mock_s3_deprecated