From 6be50a4f0a7a96c1b01975c70443e59ea5763158 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 20 Dec 2019 17:03:00 -0800 Subject: [PATCH] dilate/test_manager: tolerate Mock endpoints This test was incorrectly exercising a member of the endpoint record returned by `Manager.get_endpoints()`. In the test environment, the `.listen` Endpoint is actually a Mock, so calling e.g. `listen()` on `endpoints.listen` returns another Mock instead of a Deferred. Twisted's `assertNoResult` used to tolerate this silently, but as of Twisted-19.10 it throws an error, causing the test to fail. The fix is to assert that the record has attributes with the right names, but not assume they behave like normal Endpoints, and not call `.listen()` on them. closes #366 --- src/wormhole/test/dilate/test_manager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wormhole/test/dilate/test_manager.py b/src/wormhole/test/dilate/test_manager.py index d8aa8ab..d2c9d99 100644 --- a/src/wormhole/test/dilate/test_manager.py +++ b/src/wormhole/test/dilate/test_manager.py @@ -237,6 +237,11 @@ class TestManager(unittest.TestCase): ]) clear_mock_calls(h.inbound) + eps = m.get_endpoints() + self.assertTrue(hasattr(eps, "control")) + self.assertTrue(hasattr(eps, "connect")) + self.assertEqual(eps.listen, h.listen_ep) + m.got_wormhole_versions({"can-dilate": ["1"]}) self.assertEqual(h.send.mock_calls, [ mock.call.send("dilate-0", @@ -244,9 +249,6 @@ class TestManager(unittest.TestCase): ]) clear_mock_calls(h.send) - listen_d = m.get_endpoints().listen.listen(None) - self.assertNoResult(listen_d) - # ignore early hints m.rx_HINTS({}) self.assertEqual(h.send.mock_calls, []) @@ -267,8 +269,6 @@ class TestManager(unittest.TestCase): self.assertEqual(c.mock_calls, [mock.call.start()]) clear_mock_calls(connector, c) - self.assertNoResult(listen_d) - # now any inbound hints should get passed to our Connector with mock.patch("wormhole._dilation.manager.parse_hint", side_effect=["p1", None, "p3"]) as ph: