From 805be03142f4104403168ec2ac887d79e987d6f2 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 9 Apr 2026 20:01:45 +0100 Subject: [PATCH 1/3] Remove unnecessary calls to `self.pump` --- tests/crypto/test_keyring.py | 1 - tests/federation/test_complexity.py | 10 ------ tests/federation/test_federation_catch_up.py | 1 - tests/http/test_matrixfederationclient.py | 22 ------------ tests/http/test_simple_client.py | 7 ---- tests/media/test_media_storage.py | 2 -- tests/push/test_http.py | 37 -------------------- tests/replication/test_multi_media_repo.py | 29 --------------- tests/rest/client/test_filter.py | 1 - tests/storage/databases/main/test_lock.py | 5 --- tests/storage/databases/main/test_metrics.py | 1 - tests/storage/test_client_ips.py | 2 -- tests/storage/test_roommember.py | 4 --- 13 files changed, 122 deletions(-) diff --git a/tests/crypto/test_keyring.py b/tests/crypto/test_keyring.py index 6bc935f2720..3ff408b5eaf 100644 --- a/tests/crypto/test_keyring.py +++ b/tests/crypto/test_keyring.py @@ -188,7 +188,6 @@ async def second_lookup() -> None: d2 = ensureDeferred(second_lookup()) - self.pump() # the second request should be pending, but the fetcher should not yet have been # called self.assertEqual(second_lookup_state[0], 1) diff --git a/tests/federation/test_complexity.py b/tests/federation/test_complexity.py index 87b9ffc0c6e..c58e20a07e7 100644 --- a/tests/federation/test_complexity.py +++ b/tests/federation/test_complexity.py @@ -94,8 +94,6 @@ def test_join_too_large(self) -> None: {"membership": "join"}, ) - self.pump() - # The request failed with a SynapseError saying the resource limit was # exceeded. f = self.get_failure(d, SynapseError) @@ -125,8 +123,6 @@ def test_join_too_large_admin(self) -> None: {"membership": "join"}, ) - self.pump() - # The request failed with a SynapseError saying the resource limit was # exceeded. f = self.get_failure(d, SynapseError) @@ -170,8 +166,6 @@ async def get_current_state_event_counts(room_id: str) -> int: {"membership": "join"}, ) - self.pump() - # The request failed with a SynapseError saying the resource limit was # exceeded. f = self.get_failure(d, SynapseError) @@ -221,8 +215,6 @@ def test_join_too_large_no_admin(self) -> None: {"membership": "join"}, ) - self.pump() - # The request failed with a SynapseError saying the resource limit was # exceeded. f = self.get_failure(d, SynapseError) @@ -251,7 +243,5 @@ def test_join_too_large_admin(self) -> None: {"membership": "join"}, ) - self.pump() - # The request success since the user is an admin self.get_success(d) diff --git a/tests/federation/test_federation_catch_up.py b/tests/federation/test_federation_catch_up.py index fd1ef043bb8..dc84d5b0ee0 100644 --- a/tests/federation/test_federation_catch_up.py +++ b/tests/federation/test_federation_catch_up.py @@ -153,7 +153,6 @@ def test_catch_up_last_successful_stream_ordering_tracking(self) -> None: ) self.helper.send(room, "wombats!", tok=u1_token) - self.pump() lsso_1 = self.get_success( self.hs.get_datastores().main.get_destination_last_successful_stream_ordering( diff --git a/tests/http/test_matrixfederationclient.py b/tests/http/test_matrixfederationclient.py index 4792bdc9bc1..4d083c30ed3 100644 --- a/tests/http/test_matrixfederationclient.py +++ b/tests/http/test_matrixfederationclient.py @@ -133,8 +133,6 @@ def do_request() -> Generator["Deferred[Any]", object, object]: b"%s" % (len(res_json), res_json) ) - self.pump() - res = self.successResultOf(test_d) # check the response is as expected @@ -710,8 +708,6 @@ def test_json_error(self, return_value: bytes) -> None: b"%s" % (len(return_value), return_value) ) - self.pump() - f = self.failureResultOf(test_d) self.assertIsInstance(f.value, RequestSendFailed) @@ -751,8 +747,6 @@ def test_too_big(self) -> None: b"HTTP/1.1 200 OK\r\nServer: Fake\r\nContent-Type: application/json\r\n\r\n" ) - self.pump() - # should still be waiting self.assertNoResult(test_d) @@ -853,9 +847,6 @@ def test_proxy_requests_through_federation_sender_worker(self) -> None: self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") ) - # Pump the reactor so our deferred goes through the motions - self.pump() - # Make sure that the request was proxied through the `federation_sender` worker mock_agent_on_federation_sender.request.assert_called_once_with( b"GET", @@ -905,11 +896,6 @@ def test_proxy_request_with_network_error_through_federation_sender_worker( self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") ) - # Pump the reactor so our deferred goes through the motions. We pump with 10 - # seconds (0.1 * 100) so the `MatrixFederationHttpClient` runs out of retries - # and finally passes along the error response. - self.pump(0.1) - # Make sure that the request was proxied through the `federation_sender` worker mock_agent_on_federation_sender.request.assert_called_with( b"GET", @@ -984,9 +970,6 @@ def test_proxy_requests_and_discards_hop_by_hop_headers(self) -> None: ) ) - # Pump the reactor so our deferred goes through the motions - self.pump() - # Make sure that the request was proxied through the `federation_sender` worker mock_agent_on_federation_sender.request.assert_called_once_with( b"GET", @@ -1078,11 +1061,6 @@ def test_not_able_to_proxy_requests_through_federation_sender_worker_when_wrong_ self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") ) - # Pump the reactor so our deferred goes through the motions. We pump with 10 - # seconds (0.1 * 100) so the `MatrixFederationHttpClient` runs out of retries - # and finally passes along the error response. - self.pump(0.1) - # Make sure that the request was *NOT* proxied through the `federation_sender` # worker mock_agent_on_federation_sender.request.assert_not_called() diff --git a/tests/http/test_simple_client.py b/tests/http/test_simple_client.py index 25c0e1081b3..774926b5e8b 100644 --- a/tests/http/test_simple_client.py +++ b/tests/http/test_simple_client.py @@ -46,7 +46,6 @@ def test_dns_error(self) -> None: If the DNS lookup returns an error, it will bubble up. """ d = defer.ensureDeferred(self.cl.get_json("http://testserv2:8008/foo/bar")) - self.pump() f = self.failureResultOf(d) self.assertIsInstance(f.value, DNSLookupError) @@ -54,8 +53,6 @@ def test_dns_error(self) -> None: def test_client_connection_refused(self) -> None: d = defer.ensureDeferred(self.cl.get_json("http://testserv:8008/foo/bar")) - self.pump() - # Nothing happened yet self.assertNoResult(d) @@ -79,8 +76,6 @@ def test_client_never_connect(self) -> None: """ d = defer.ensureDeferred(self.cl.get_json("http://testserv:8008/foo/bar")) - self.pump() - # Nothing happened yet self.assertNoResult(d) @@ -106,8 +101,6 @@ def test_client_connect_no_response(self) -> None: """ d = defer.ensureDeferred(self.cl.get_json("http://testserv:8008/foo/bar")) - self.pump() - # Nothing happened yet self.assertNoResult(d) diff --git a/tests/media/test_media_storage.py b/tests/media/test_media_storage.py index 631718a3666..72818bf41a5 100644 --- a/tests/media/test_media_storage.py +++ b/tests/media/test_media_storage.py @@ -845,8 +845,6 @@ def test_unknown_v3_endpoint(self) -> None: HttpResponseException(404, "NOT FOUND", unknown_endpoint) ) - self.pump() - # There should now be another request to the r0 URL. self.assertEqual(len(self.fetches), 2) self.assertEqual(self.fetches[1][1], "example.com") diff --git a/tests/push/test_http.py b/tests/push/test_http.py index ca2ced01ed0..f6a7f7755e2 100644 --- a/tests/push/test_http.py +++ b/tests/push/test_http.py @@ -159,9 +159,6 @@ def test_sends_http(self) -> None: self.assertEqual(len(pushers), 1) last_stream_ordering = pushers[0].last_stream_ordering - # Advance time a bit, so the pusher will register something has happened - self.pump() - # It hasn't succeeded yet, so the stream ordering shouldn't have moved pushers = list( self.get_success( @@ -182,7 +179,6 @@ def test_sends_http(self) -> None: # Make the push succeed self.push_attempts[0][0].callback({}) - self.pump() # The stream ordering has increased pushers = list( @@ -205,7 +201,6 @@ def test_sends_http(self) -> None: # Make the second push succeed self.push_attempts[1][0].callback({}) - self.pump() # The stream ordering has increased, again pushers = list( @@ -284,12 +279,8 @@ def test_sends_high_priority_for_encrypted(self) -> None: tok=other_access_token, ) - # Advance time a bit, so the pusher will register something has happened - self.pump() - # Make the push succeed self.push_attempts[0][0].callback({}) - self.pump() # Check our push made it with high priority self.assertEqual(len(self.push_attempts), 1) @@ -308,7 +299,6 @@ def test_sends_high_priority_for_encrypted(self) -> None: # Check no push notifications are sent regarding the membership changes # (that would confuse the test) - self.pump() self.assertEqual(len(self.push_attempts), 1) # Send another encrypted event @@ -330,8 +320,6 @@ def test_sends_high_priority_for_encrypted(self) -> None: tok=other_access_token, ) - # Advance time a bit, so the pusher will register something has happened - self.pump() self.assertEqual(len(self.push_attempts), 2) self.assertEqual( self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" @@ -385,12 +373,8 @@ def test_sends_high_priority_for_one_to_one_only(self) -> None: # Send a message self.helper.send(room, body="Hi!", tok=other_access_token) - # Advance time a bit, so the pusher will register something has happened - self.pump() - # Make the push succeed self.push_attempts[0][0].callback({}) - self.pump() # Check our push made it with high priority — this is a one-to-one room self.assertEqual(len(self.push_attempts), 1) @@ -406,14 +390,11 @@ def test_sends_high_priority_for_one_to_one_only(self) -> None: # Check no push notifications are sent regarding the membership changes # (that would confuse the test) - self.pump() self.assertEqual(len(self.push_attempts), 1) # Send another event self.helper.send(room, body="Welcome!", tok=other_access_token) - # Advance time a bit, so the pusher will register something has happened - self.pump() self.assertEqual(len(self.push_attempts), 2) self.assertEqual( self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" @@ -472,12 +453,8 @@ def test_sends_high_priority_for_mention(self) -> None: # Send a message self.helper.send(room, body="Oh, user, hello!", tok=other_access_token) - # Advance time a bit, so the pusher will register something has happened - self.pump() - # Make the push succeed self.push_attempts[0][0].callback({}) - self.pump() # Check our push made it with high priority self.assertEqual(len(self.push_attempts), 1) @@ -489,8 +466,6 @@ def test_sends_high_priority_for_mention(self) -> None: # Send another event, this time with no mention self.helper.send(room, body="Are you there?", tok=other_access_token) - # Advance time a bit, so the pusher will register something has happened - self.pump() self.assertEqual(len(self.push_attempts), 2) self.assertEqual( self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" @@ -554,12 +529,8 @@ def test_sends_high_priority_for_atroom(self) -> None: tok=other_access_token, ) - # Advance time a bit, so the pusher will register something has happened - self.pump() - # Make the push succeed self.push_attempts[0][0].callback({}) - self.pump() # Check our push made it with high priority self.assertEqual(len(self.push_attempts), 1) @@ -573,8 +544,6 @@ def test_sends_high_priority_for_atroom(self) -> None: room, body="@room the spider is gone", tok=yet_another_access_token ) - # Advance time a bit, so the pusher will register something has happened - self.pump() self.assertEqual(len(self.push_attempts), 2) self.assertEqual( self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" @@ -703,7 +672,6 @@ def _test_push_unread_count(self) -> None: self.helper.send(room_id, body="HELLO???", tok=other_access_token) def _advance_time_and_make_push_succeed(self, expected_push_attempts: int) -> None: - self.pump() self.push_attempts[expected_push_attempts - 1][0].callback({}) def _check_push_attempt( @@ -1084,7 +1052,6 @@ def test_jitter(self) -> None: index += 1 self.reactor.advance(1) - self.pump() self.assertEqual(len(self.push_attempts), 11) @@ -1150,7 +1117,6 @@ def test_msc4076_badge_count( self.helper.send(room, body="Hi!", tok=other_access_token) # Advance time a bit, so the pusher will register something has happened - self.pump() # One push was attempted to be sent self.assertEqual(len(self.push_attempts), 1) @@ -1218,17 +1184,14 @@ def test_push_backoff(self) -> None: self.push_attempts[0][2]["notification"]["content"]["body"], "Message 1" ) self.push_attempts[0][0].callback({}) - self.pump() # Send another message, this time it fails self.helper.send(room, body="Message 2", tok=other_access_token) self.assertEqual(len(self.push_attempts), 2) self.push_attempts[1][0].errback(Exception("couldn't connect")) - self.pump() # Sending yet another message doesn't trigger a push immediately self.helper.send(room, body="Message 3", tok=other_access_token) - self.pump() self.assertEqual(len(self.push_attempts), 2) # .. but waiting for a bit will cause more pushes diff --git a/tests/replication/test_multi_media_repo.py b/tests/replication/test_multi_media_repo.py index 000dbb55940..059a08c3f2c 100644 --- a/tests/replication/test_multi_media_repo.py +++ b/tests/replication/test_multi_media_repo.py @@ -97,7 +97,6 @@ def _get_media_req( access_token=self.access_token, await_result=False, ) - self.pump() clients = self.reactor.tcpClients self.assertGreaterEqual(len(clients), 1) @@ -161,8 +160,6 @@ def test_basic(self) -> None: request.write(b"Hello!") request.finish() - self.pump(0.1) - self.assertEqual(channel.code, 200) self.assertEqual(channel.result["body"], b"Hello!") @@ -187,8 +184,6 @@ def test_download_simple_file_race(self) -> None: request1.write(b"Hello!") request1.finish() - self.pump(0.1) - self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], b"Hello!") @@ -198,8 +193,6 @@ def test_download_simple_file_race(self) -> None: request2.write(b"Hello!") request2.finish() - self.pump(0.1) - self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], b"Hello!") @@ -233,8 +226,6 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request1.write(b"Hello!") request1.finish() - self.pump(0.1) - # With local storage disabled and no storage providers, # we expect a 404 error self.assertEqual(channel1.code, 404, channel1.result["body"]) @@ -245,8 +236,6 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request2.write(b"Hello!") request2.finish() - self.pump(0.1) - # Same for the second request self.assertEqual(channel2.code, 404, channel2.result["body"]) @@ -273,8 +262,6 @@ def test_download_image_race(self) -> None: request1.write(SMALL_PNG) request1.finish() - self.pump(0.1) - self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], SMALL_PNG) @@ -283,8 +270,6 @@ def test_download_image_race(self) -> None: request2.write(SMALL_PNG) request2.finish() - self.pump(0.1) - self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], SMALL_PNG) @@ -359,7 +344,6 @@ def _get_media_req( access_token=self.access_token, await_result=False, ) - self.pump() clients = self.reactor.tcpClients self.assertGreaterEqual(len(clients), 1) @@ -425,8 +409,6 @@ def test_basic(self) -> None: request.write(self.file_data) request.finish() - self.pump(0.1) - self.assertEqual(channel.code, 200) self.assertEqual(channel.result["body"], b"file_to_stream") @@ -453,8 +435,6 @@ def test_download_simple_file_race(self) -> None: request1.write(self.file_data) request1.finish() - self.pump(0.1) - self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], b"file_to_stream") @@ -467,8 +447,6 @@ def test_download_simple_file_race(self) -> None: request2.write(self.file_data) request2.finish() - self.pump(0.1) - self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], b"file_to_stream") @@ -501,7 +479,6 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request1.write(self.file_data) request1.finish() - self.pump(0.1) # With local storage disabled and no storage providers, # we expect a 404 error self.assertEqual(channel1.code, 404, channel1.result["body"]) @@ -515,8 +492,6 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request2.write(self.file_data) request2.finish() - self.pump(0.1) - self.assertEqual(channel2.code, 404, channel2.result["body"]) # With local storage disabled, no files should be stored locally @@ -547,8 +522,6 @@ def test_download_image_race(self) -> None: request1.write(b"\r\n--6067d4698f8d40a0a794ea7d7379d53a--\r\n\r\n") request1.finish() - self.pump(0.1) - self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], SMALL_PNG) @@ -562,8 +535,6 @@ def test_download_image_race(self) -> None: request2.write(b"\r\n--6067d4698f8d40a0a794ea7d7379d53a--\r\n\r\n") request2.finish() - self.pump(0.1) - self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], SMALL_PNG) diff --git a/tests/rest/client/test_filter.py b/tests/rest/client/test_filter.py index 0897c67ac3f..3e9d999cd7f 100644 --- a/tests/rest/client/test_filter.py +++ b/tests/rest/client/test_filter.py @@ -57,7 +57,6 @@ def test_add_filter(self) -> None: user_id=UserID.from_string(FilterTestCase.user_id), filter_id=0 ) ) - self.pump() self.assertEqual(filter, self.EXAMPLE_FILTER) def test_add_filter_for_other_user(self) -> None: diff --git a/tests/storage/databases/main/test_lock.py b/tests/storage/databases/main/test_lock.py index 622eb96ded0..493c1194deb 100644 --- a/tests/storage/databases/main/test_lock.py +++ b/tests/storage/databases/main/test_lock.py @@ -66,16 +66,11 @@ async def task() -> None: task2 = defer.ensureDeferred(task()) task3 = defer.ensureDeferred(task()) - # Give the reactor a kick so that the database transaction returns. - self.pump() - release_lock.callback(None) # Run the tasks to completion. self.get_success(task1) - self.pump() self.get_success(task2) - self.pump() self.get_success(task3) # At most one task should have held the lock at a time. diff --git a/tests/storage/databases/main/test_metrics.py b/tests/storage/databases/main/test_metrics.py index be59e1b67e2..c0acdb83f9a 100644 --- a/tests/storage/databases/main/test_metrics.py +++ b/tests/storage/databases/main/test_metrics.py @@ -55,7 +55,6 @@ def test_exposed_to_prometheus(self) -> None: # Let it run for a while, then pull out the statistics from the # Prometheus client registry self.reactor.advance(60 * 60 * 1000) - self.pump(1) items = list( filter( diff --git a/tests/storage/test_client_ips.py b/tests/storage/test_client_ips.py index bd68f2aaa1e..1a484e19f48 100644 --- a/tests/storage/test_client_ips.py +++ b/tests/storage/test_client_ips.py @@ -101,7 +101,6 @@ def test_insert_new_client_ip_none_device_id(self) -> None: ) ) self.reactor.advance(200) - self.pump(0) result = cast( list[tuple[str, str, str, str | None, int]], @@ -132,7 +131,6 @@ def test_insert_new_client_ip_none_device_id(self) -> None: ) ) self.reactor.advance(10) - self.pump(0) result = cast( list[tuple[str, str, str, str | None, int]], diff --git a/tests/storage/test_roommember.py b/tests/storage/test_roommember.py index f8d64e8ce68..abc08f69b7d 100644 --- a/tests/storage/test_roommember.py +++ b/tests/storage/test_roommember.py @@ -100,8 +100,6 @@ def test_count_known_servers_stat_counter_disabled(self) -> None: self.inject_room_member(self.room, self.u_bob, Membership.JOIN) self.inject_room_member(self.room, self.u_charlie.to_string(), Membership.JOIN) - self.pump() - self.assertTrue("_known_servers_count" not in self.store.__dict__.keys()) @unittest.override_config( @@ -114,8 +112,6 @@ def test_count_known_servers_stat_counter_enabled(self) -> None: # Initialises to 1 -- itself self.assertEqual(self.store._known_servers_count, 1) - self.pump() - # No rooms have been joined, so technically the SQL returns 0, but it # will still say it knows about itself. self.assertEqual(self.store._known_servers_count, 1) From b95486db7a3511cec4f97db9f013328252d59bb3 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Fri, 10 Apr 2026 17:10:28 +0100 Subject: [PATCH 2/3] Reinstate pumps needed by Postgres tests --- tests/http/test_matrixfederationclient.py | 12 ++++++ tests/replication/test_multi_media_repo.py | 48 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/tests/http/test_matrixfederationclient.py b/tests/http/test_matrixfederationclient.py index 4d083c30ed3..feab304f9ae 100644 --- a/tests/http/test_matrixfederationclient.py +++ b/tests/http/test_matrixfederationclient.py @@ -847,6 +847,9 @@ def test_proxy_requests_through_federation_sender_worker(self) -> None: self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") ) + # Needed under Postgres + self.pump() + # Make sure that the request was proxied through the `federation_sender` worker mock_agent_on_federation_sender.request.assert_called_once_with( b"GET", @@ -896,6 +899,9 @@ def test_proxy_request_with_network_error_through_federation_sender_worker( self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") ) + # Needed under Postgres + self.pump(0.1) + # Make sure that the request was proxied through the `federation_sender` worker mock_agent_on_federation_sender.request.assert_called_with( b"GET", @@ -970,6 +976,9 @@ def test_proxy_requests_and_discards_hop_by_hop_headers(self) -> None: ) ) + # Needed under Postgres + self.pump() + # Make sure that the request was proxied through the `federation_sender` worker mock_agent_on_federation_sender.request.assert_called_once_with( b"GET", @@ -1061,6 +1070,9 @@ def test_not_able_to_proxy_requests_through_federation_sender_worker_when_wrong_ self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") ) + # Needed under Postgres + self.pump(0.1) + # Make sure that the request was *NOT* proxied through the `federation_sender` # worker mock_agent_on_federation_sender.request.assert_not_called() diff --git a/tests/replication/test_multi_media_repo.py b/tests/replication/test_multi_media_repo.py index 059a08c3f2c..cc2850dc142 100644 --- a/tests/replication/test_multi_media_repo.py +++ b/tests/replication/test_multi_media_repo.py @@ -98,6 +98,9 @@ def _get_media_req( await_result=False, ) + # Needed under Postgres + self.pump() + clients = self.reactor.tcpClients self.assertGreaterEqual(len(clients), 1) (host, port, client_factory, _timeout, _bindAddress) = clients.pop() @@ -160,6 +163,9 @@ def test_basic(self) -> None: request.write(b"Hello!") request.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel.code, 200) self.assertEqual(channel.result["body"], b"Hello!") @@ -184,6 +190,9 @@ def test_download_simple_file_race(self) -> None: request1.write(b"Hello!") request1.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], b"Hello!") @@ -193,6 +202,9 @@ def test_download_simple_file_race(self) -> None: request2.write(b"Hello!") request2.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], b"Hello!") @@ -226,6 +238,9 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request1.write(b"Hello!") request1.finish() + # Needed under Postgres + self.pump(0.1) + # With local storage disabled and no storage providers, # we expect a 404 error self.assertEqual(channel1.code, 404, channel1.result["body"]) @@ -236,6 +251,9 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request2.write(b"Hello!") request2.finish() + # Needed under Postgres + self.pump(0.1) + # Same for the second request self.assertEqual(channel2.code, 404, channel2.result["body"]) @@ -262,6 +280,9 @@ def test_download_image_race(self) -> None: request1.write(SMALL_PNG) request1.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], SMALL_PNG) @@ -270,6 +291,9 @@ def test_download_image_race(self) -> None: request2.write(SMALL_PNG) request2.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], SMALL_PNG) @@ -345,6 +369,9 @@ def _get_media_req( await_result=False, ) + # Needed under Postgres + self.pump() + clients = self.reactor.tcpClients self.assertGreaterEqual(len(clients), 1) (host, port, client_factory, _timeout, _bindAddress) = clients.pop() @@ -409,6 +436,9 @@ def test_basic(self) -> None: request.write(self.file_data) request.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel.code, 200) self.assertEqual(channel.result["body"], b"file_to_stream") @@ -435,6 +465,9 @@ def test_download_simple_file_race(self) -> None: request1.write(self.file_data) request1.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], b"file_to_stream") @@ -447,6 +480,9 @@ def test_download_simple_file_race(self) -> None: request2.write(self.file_data) request2.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], b"file_to_stream") @@ -479,6 +515,9 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request1.write(self.file_data) request1.finish() + # Needed under Postgres + self.pump(0.1) + # With local storage disabled and no storage providers, # we expect a 404 error self.assertEqual(channel1.code, 404, channel1.result["body"]) @@ -492,6 +531,9 @@ def test_download_simple_file_race_no_local_storage(self) -> None: request2.write(self.file_data) request2.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel2.code, 404, channel2.result["body"]) # With local storage disabled, no files should be stored locally @@ -522,6 +564,9 @@ def test_download_image_race(self) -> None: request1.write(b"\r\n--6067d4698f8d40a0a794ea7d7379d53a--\r\n\r\n") request1.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel1.code, 200, channel1.result["body"]) self.assertEqual(channel1.result["body"], SMALL_PNG) @@ -535,6 +580,9 @@ def test_download_image_race(self) -> None: request2.write(b"\r\n--6067d4698f8d40a0a794ea7d7379d53a--\r\n\r\n") request2.finish() + # Needed under Postgres + self.pump(0.1) + self.assertEqual(channel2.code, 200, channel2.result["body"]) self.assertEqual(channel2.result["body"], SMALL_PNG) From e41fbccb810e3107dce00e258e9ca35167c73a12 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 9 Apr 2026 20:08:29 +0100 Subject: [PATCH 3/3] Newsfile Signed-off-by: Olivier 'reivilibre --- changelog.d/19676.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/19676.misc diff --git a/changelog.d/19676.misc b/changelog.d/19676.misc new file mode 100644 index 00000000000..097750ad977 --- /dev/null +++ b/changelog.d/19676.misc @@ -0,0 +1 @@ +Remove unnecessary `self.pump` calls in some of our tests. \ No newline at end of file