1010BUCKET_NAME = "fake-bucket"
1111KEY = "unwrapped/20231009_20231021.unw.tif"
1212URL = f"s3://{ BUCKET_NAME } /{ KEY } "
13+ PORT = 5123
14+ LOCALHOST_URL = f"http://localhost:{ PORT } "
15+ LOCALHOST_ENDPOINT = f"localhost:{ PORT } "
1316
1417pytestmark = pytest .mark .filterwarnings (
1518 # Dataset has no geotransform, gcps, or rpcs. The identity matrix will be returned.
@@ -37,22 +40,22 @@ def moto_server_handler(monkeymodule):
3740 with open (f .name , "rb" ) as fout :
3841 arr_bytes = fout .read ()
3942
40- local_server = ThreadedMotoServer (ip_address = "127.0.0.1" , port = 5000 )
43+ local_server = ThreadedMotoServer (ip_address = "127.0.0.1" , port = PORT )
4144 local_server .start ()
4245
4346 monkeymodule .setenv ("AWS_ACCESS_KEY_ID" , "testing" )
4447 monkeymodule .setenv ("AWS_SECRET_ACCESS_KEY" , "testing" )
4548 monkeymodule .setenv ("AWS_SECURITY_TOKEN" , "testing" )
4649 monkeymodule .setenv ("AWS_SESSION_TOKEN" , "testing" )
4750 monkeymodule .setenv ("AWS_DEFAULT_REGION" , "us-east-1" )
48- monkeymodule .setenv ("AWS_ENDPOINT_URL" , "http://localhost:5000" )
51+ monkeymodule .setenv ("AWS_ENDPOINT_URL" , LOCALHOST_URL )
4952
5053 # Post the dummy file to the local server
5154 with mock_aws ():
5255 s3 = boto3 .resource (
5356 service_name = "s3" ,
5457 region_name = "us-east-1" ,
55- endpoint_url = "http://localhost:5000" ,
58+ endpoint_url = LOCALHOST_URL ,
5659 )
5760
5861 b = s3 .create_bucket (Bucket = BUCKET_NAME )
@@ -95,7 +98,7 @@ def test_rasterio_open(self, s3path):
9598 with rio .Env (
9699 aws_unsigned = True ,
97100 AWS_HTTPS = "NO" ,
98- AWS_S3_ENDPOINT = "localhost:5000" ,
101+ AWS_S3_ENDPOINT = LOCALHOST_ENDPOINT ,
99102 ):
100103 with rio .open (URL ) as src :
101104 driver , shape = src .driver , src .shape
@@ -113,7 +116,7 @@ def test_io_read_gdal(self, s3path):
113116 with gdal .config_options (
114117 {
115118 "AWS_NO_SIGN_REQUEST" : "YES" ,
116- "AWS_S3_ENDPOINT" : "localhost:5000" ,
119+ "AWS_S3_ENDPOINT" : LOCALHOST_ENDPOINT ,
117120 "AWS_HTTPS" : "NO" ,
118121 }
119122 ):
0 commit comments