Skip to content

Commit

Permalink
Fix FileReadWriteTestCase test
Browse files Browse the repository at this point in the history
Attempted to use patch.dict, however it did not work for reasons unknown
  • Loading branch information
Fireye04 committed Mar 3, 2023
1 parent 782c379 commit d44b304
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/changes/DM-37439.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix invalid endpoint error in the FileReadWriteTestCase test when the `S3_ENDPOINT_URL` environment variable is set to an invalid endpoint.
10 changes: 10 additions & 0 deletions tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Use of this source code is governed by a 3-clause BSD-style
# license that can be found in the LICENSE file.

import os
import unittest

from lsst.resources import ResourcePath
Expand Down Expand Up @@ -43,6 +44,12 @@ def setUp(self):
# Enable S3 mocking of tests.
self.mock_s3.start()

self.endpoint = None

if "S3_ENDPOINT_URL" in os.environ:
self.endpoint = os.environ["S3_ENDPOINT_URL"]
os.environ["S3_ENDPOINT_URL"] = ""

# set up some fake credentials if they do not exist
# self.usingDummyCredentials = setAwsEnvCredentials()

Expand All @@ -67,6 +74,9 @@ def tearDown(self):
bucket = s3.Bucket(self.netloc)
bucket.delete()

if self.endpoint is not None:
os.environ["S3_ENDPOINT_URL"] = self.endpoint

# Stop the S3 mock.
self.mock_s3.stop()

Expand Down

0 comments on commit d44b304

Please sign in to comment.