Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/19486.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename the `test_disconnect` test helper so that pytest doesn't see it as a test.
6 changes: 3 additions & 3 deletions tests/federation/transport/server/test__base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from synapse.util.ratelimitutils import FederationRateLimiter

from tests import unittest
from tests.http.server._base import test_disconnect
from tests.http.server._base import disconnect_and_assert


class CancellableFederationServlet(BaseFederationServlet):
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_cancellable_disconnect(self) -> None:
# request won't be processed.
self.pump()

test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=True,
Expand All @@ -114,7 +114,7 @@ def test_uncancellable_disconnect(self) -> None:
# request won't be processed.
self.pump()

test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/http/server/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
T = TypeVar("T")


def test_disconnect(
def disconnect_and_assert(
reactor: MemoryReactorClock,
channel: FakeChannel,
expect_cancellation: bool,
Expand Down
6 changes: 3 additions & 3 deletions tests/http/test_servlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from synapse.util.duration import Duration

from tests import unittest
from tests.http.server._base import test_disconnect
from tests.http.server._base import disconnect_and_assert


def make_request(content: bytes | JsonDict) -> Mock:
Expand Down Expand Up @@ -127,7 +127,7 @@ class TestRestServletCancellation(unittest.HomeserverTestCase):
def test_cancellable_disconnect(self) -> None:
"""Test that handlers with the `@cancellable` flag can be cancelled."""
channel = self.make_request("GET", "/sleep", await_result=False)
test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=True,
Expand All @@ -137,7 +137,7 @@ def test_cancellable_disconnect(self) -> None:
def test_uncancellable_disconnect(self) -> None:
"""Test that handlers without the `@cancellable` flag cannot be cancelled."""
channel = self.make_request("POST", "/sleep", await_result=False)
test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=False,
Expand Down
6 changes: 3 additions & 3 deletions tests/replication/http/test__base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from synapse.util.duration import Duration

from tests import unittest
from tests.http.server._base import test_disconnect
from tests.http.server._base import disconnect_and_assert


class CancellableReplicationEndpoint(ReplicationEndpoint):
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_cancellable_disconnect(self) -> None:
"""Test that handlers with the `@cancellable` flag can be cancelled."""
path = f"{REPLICATION_PREFIX}/{CancellableReplicationEndpoint.NAME}/"
channel = self.make_request("POST", path, await_result=False, content={})
test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=True,
Expand All @@ -105,7 +105,7 @@ def test_uncancellable_disconnect(self) -> None:
"""Test that handlers without the `@cancellable` flag cannot be cancelled."""
path = f"{REPLICATION_PREFIX}/{UncancellableReplicationEndpoint.NAME}/"
channel = self.make_request("POST", path, await_result=False, content={})
test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=False,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from synapse.util.duration import Duration

from tests import unittest
from tests.http.server._base import test_disconnect
from tests.http.server._base import disconnect_and_assert
from tests.server import (
FakeChannel,
FakeSite,
Expand Down Expand Up @@ -506,7 +506,7 @@ def test_cancellable_disconnect(self) -> None:
channel = make_request(
self.reactor, self.site, "GET", "/sleep", await_result=False
)
test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=True,
Expand All @@ -518,7 +518,7 @@ def test_uncancellable_disconnect(self) -> None:
channel = make_request(
self.reactor, self.site, "POST", "/sleep", await_result=False
)
test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=False,
Expand All @@ -540,7 +540,7 @@ def test_cancellable_disconnect(self) -> None:
channel = make_request(
self.reactor, self.site, "GET", "/sleep", await_result=False
)
test_disconnect(
disconnect_and_assert(
self.reactor,
channel,
expect_cancellation=True,
Expand All @@ -552,6 +552,6 @@ def test_uncancellable_disconnect(self) -> None:
channel = make_request(
self.reactor, self.site, "POST", "/sleep", await_result=False
)
test_disconnect(
disconnect_and_assert(
self.reactor, channel, expect_cancellation=False, expected_body=b"ok"
)