summary refs log tree commit diff
path: root/tests/rest/client
diff options
context:
space:
mode:
authorErik Johnston <erikj@element.io>2024-05-29 11:14:42 +0100
committerGitHub <noreply@github.com>2024-05-29 11:14:42 +0100
commitbb5a692946e69c7f3686f1cb3fc0833b736f066a (patch)
tree6fccac75d6c8b4205d5eb1129a2e17003d60aeaf /tests/rest/client
parentMerge branch 'master' into develop (diff)
downloadsynapse-bb5a692946e69c7f3686f1cb3fc0833b736f066a.tar.xz
Fix slipped logging context when media rejected (#17239)
When a module rejects a piece of media we end up trying to close the
same logging context twice.

Instead of fixing the existing code we refactor to use an async context
manager, which is easier to write correctly.
Diffstat (limited to 'tests/rest/client')
-rw-r--r--tests/rest/client/test_media.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/rest/client/test_media.py b/tests/rest/client/test_media.py
index 600cbf8963..be4a289ec1 100644
--- a/tests/rest/client/test_media.py
+++ b/tests/rest/client/test_media.py
@@ -93,13 +93,13 @@ class UnstableMediaDomainBlockingTests(unittest.HomeserverTestCase):
         # from a regular 404.
         file_id = "abcdefg12345"
         file_info = FileInfo(server_name=self.remote_server_name, file_id=file_id)
-        with hs.get_media_repository().media_storage.store_into_file(file_info) as (
-            f,
-            fname,
-            finish,
-        ):
-            f.write(SMALL_PNG)
-            self.get_success(finish())
+
+        media_storage = hs.get_media_repository().media_storage
+
+        ctx = media_storage.store_into_file(file_info)
+        (f, fname) = self.get_success(ctx.__aenter__())
+        f.write(SMALL_PNG)
+        self.get_success(ctx.__aexit__(None, None, None))
 
         self.get_success(
             self.store.store_cached_remote_media(