mirror of https://github.com/zulip/zulip.git
tests: Fix order of mock.patch in use_s3_backend.
This is a somewhat hacky and fragile fix. Due to the order in which imports seem to happen, the original ordering breaks RealmImportExportTest: if one of the `use_s3_backend` tests runs before test_import_realm, the latter will fail while processing thumbnailing, as S3UploadBackend ends up leaking and zerver.worker.thumbnail.upload_backend is still set to S3. By making that mock.patch the first one that gets entered, and thus the last one to get cleaned up, we fix the leak and upload_backend is set back to LocalUploadBackend as it should.
This commit is contained in:
parent
eb31fdbe3c
commit
d708a1bea5
|
@ -603,8 +603,8 @@ def use_s3_backend(method: Callable[P, None]) -> Callable[P, None]:
|
|||
def new_method(*args: P.args, **kwargs: P.kwargs) -> None:
|
||||
backend = S3UploadBackend()
|
||||
with (
|
||||
mock.patch("zerver.lib.upload.upload_backend", backend),
|
||||
mock.patch("zerver.worker.thumbnail.upload_backend", backend),
|
||||
mock.patch("zerver.lib.upload.upload_backend", backend),
|
||||
mock.patch("zerver.views.tusd.upload_backend", backend),
|
||||
):
|
||||
return method(*args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue