Skip to content

Commit

Permalink
Don't use a mock
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jul 2, 2023
1 parent 340015c commit 9e124e9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/twisted/test/test_defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
Union,
cast,
)
from unittest.mock import Mock

from hamcrest import assert_that, empty, equal_to, is_
from hypothesis import given
Expand Down Expand Up @@ -1688,10 +1687,10 @@ def test_inlineCallbacksCancelCaptured(self) -> None:
Cancelling an `inlineCallbacks` correctly handles the function catching
the `CancelledError`.
"""
cancellerMock1 = Mock()
cancellerMock2 = Mock()
d1: Deferred[Any] = Deferred(cancellerMock1)
d2: Deferred[Any] = Deferred(cancellerMock2)
canceller1Calls: List[Deferred[Any]] = []
canceller2Calls: List[Deferred[Any]] = []
d1: Deferred[Any] = Deferred(canceller1Calls.append)
d2: Deferred[Any] = Deferred(canceller2Calls.append)

@defer.inlineCallbacks
def testFunc() -> Any:
Expand All @@ -1707,12 +1706,12 @@ def testFunc() -> Any:

funcD.cancel()

cancellerMock1.assert_called_once()
self.assertEqual(canceller1Calls, [d1])

funcD.cancel()
self.failureResultOf(funcD)

cancellerMock2.assert_called_once()
self.assertEqual(canceller2Calls, [d2])

@pyunit.skipIf(_PYPY, "GC works differently on PyPy.")
def test_canceller_circular_reference_callback(self) -> None:
Expand Down

0 comments on commit 9e124e9

Please sign in to comment.