| 42 | |
| 43 | @pytest.fixture |
| 44 | def s3_bucket(s3_server): |
| 45 | boto3 = pytest.importorskip('boto3') |
| 46 | botocore = pytest.importorskip('botocore') |
| 47 | s3_bucket_name = 'test-s3fs' |
| 48 | |
| 49 | host, port, access_key, secret_key = s3_server['connection'] |
| 50 | s3_client = boto3.client( |
| 51 | 's3', |
| 52 | endpoint_url=f'http://{host}:{port}', |
| 53 | aws_access_key_id=access_key, |
| 54 | aws_secret_access_key=secret_key, |
| 55 | config=botocore.client.Config(signature_version='s3v4'), |
| 56 | region_name='us-east-1' |
| 57 | ) |
| 58 | |
| 59 | try: |
| 60 | s3_client.create_bucket(Bucket=s3_bucket_name) |
| 61 | except Exception: |
| 62 | pass # we get BucketAlreadyOwnedByYou error with fsspec handler |
| 63 | finally: |
| 64 | s3_client.close() |
| 65 | |
| 66 | return s3_bucket_name |
| 67 | |
| 68 | |
| 69 | @pytest.fixture |