Fix tests.

This commit is contained in:
Itamar Turner-Trauring 2023-05-10 16:34:02 -04:00
parent c92c93e6d5
commit ba9946e6ea
2 changed files with 7 additions and 3 deletions

View File

@ -310,7 +310,7 @@ class StorageClient(object):
_base_url: DecodedURL
_swissnum: bytes
_treq: Union[treq, StubTreq, HTTPClient]
_pool: HTTPConnectionPool
_pool: Optional[HTTPConnectionPool]
_clock: IReactorTime
@classmethod
@ -482,7 +482,8 @@ class StorageClient(object):
def shutdown(self) -> Deferred:
"""Shutdown any connections."""
return self._pool.closeCachedConnections()
if self._pool is not None:
return self._pool.closeCachedConnections()
@define(hash=True)

View File

@ -331,6 +331,7 @@ class CustomHTTPServerTests(SyncTestCase):
DecodedURL.from_text("http://127.0.0.1"),
SWISSNUM_FOR_TEST,
treq=treq,
pool=None,
# We're using a Treq private API to get the reactor, alas, but only
# in a test, so not going to worry about it too much. This would be
# fixed if https://github.com/twisted/treq/issues/226 were ever
@ -512,6 +513,7 @@ class HttpTestFixture(Fixture):
DecodedURL.from_text("http://127.0.0.1"),
SWISSNUM_FOR_TEST,
treq=self.treq,
pool=None,
clock=self.clock,
)
@ -624,6 +626,7 @@ class GenericHTTPAPITests(SyncTestCase):
DecodedURL.from_text("http://127.0.0.1"),
b"something wrong",
treq=StubTreq(self.http.http_server.get_resource()),
pool=None,
clock=self.http.clock,
)
)
@ -1455,7 +1458,7 @@ class SharedImmutableMutableTestsMixin:
self.client.advise_corrupt_share(storage_index, 13, reason)
)
for (si, share_number) in [(storage_index, 11), (urandom(16), 13)]:
for si, share_number in [(storage_index, 11), (urandom(16), 13)]:
with assert_fails_with_http_code(self, http.NOT_FOUND):
self.http.result_of_with_flush(
self.client.advise_corrupt_share(si, share_number, reason)