Stop test mode when done.

This commit is contained in:
Itamar Turner-Trauring 2022-11-15 14:21:31 -05:00
parent 4aeb62b66c
commit 8e4ac69032
3 changed files with 8 additions and 0 deletions

View File

@ -297,6 +297,11 @@ class StorageClient(object):
""" """
cls.TEST_MODE_REGISTER_HTTP_POOL = callback cls.TEST_MODE_REGISTER_HTTP_POOL = callback
@classmethod
def stop_test_mode(cls):
"""Stop testing mode."""
cls.TEST_MODE_REGISTER_HTTP_POOL = None
# The URL is a HTTPS URL ("https://..."). To construct from a NURL, use # The URL is a HTTPS URL ("https://..."). To construct from a NURL, use
# ``StorageClient.from_nurl()``. # ``StorageClient.from_nurl()``.
_base_url: DecodedURL _base_url: DecodedURL

View File

@ -649,6 +649,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
def setUp(self): def setUp(self):
self._http_client_pools = [] self._http_client_pools = []
http_client.StorageClient.start_test_mode(self._http_client_pools.append) http_client.StorageClient.start_test_mode(self._http_client_pools.append)
self.addCleanup(http_client.StorageClient.stop_test_mode)
self.port_assigner = SameProcessStreamEndpointAssigner() self.port_assigner = SameProcessStreamEndpointAssigner()
self.port_assigner.setUp() self.port_assigner.setUp()
self.addCleanup(self.port_assigner.tearDown) self.addCleanup(self.port_assigner.tearDown)

View File

@ -294,6 +294,7 @@ class CustomHTTPServerTests(SyncTestCase):
StorageClient.start_test_mode( StorageClient.start_test_mode(
lambda pool: self.addCleanup(pool.closeCachedConnections) lambda pool: self.addCleanup(pool.closeCachedConnections)
) )
self.addCleanup(StorageClient.stop_test_mode)
# Could be a fixture, but will only be used in this test class so not # Could be a fixture, but will only be used in this test class so not
# going to bother: # going to bother:
self._http_server = TestApp() self._http_server = TestApp()
@ -382,6 +383,7 @@ class HttpTestFixture(Fixture):
StorageClient.start_test_mode( StorageClient.start_test_mode(
lambda pool: self.addCleanup(pool.closeCachedConnections) lambda pool: self.addCleanup(pool.closeCachedConnections)
) )
self.addCleanup(StorageClient.stop_test_mode)
self.clock = Clock() self.clock = Clock()
self.tempdir = self.useFixture(TempDir()) self.tempdir = self.useFixture(TempDir())
# The global Cooperator used by Twisted (a) used by pull producers in # The global Cooperator used by Twisted (a) used by pull producers in