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
11 changes: 11 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ testtools NEWS

Changes and improvements to testtools_, grouped by release.

NEXT
~~~~

Improvements
------------

* Make ``extract_result()`` and ``DeferredNotFired`` public APIs in
``testtools.twistedsupport``. These utilities are useful for extracting
results from synchronous Deferreds in tests.
(Jelmer Vernooij, #546)

2.8.3
~~~~~

Expand Down
14 changes: 14 additions & 0 deletions doc/twisted-support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ See also `Testing Deferreds without the reactor`_ and the `Deferred howto`_.
:noindex:


Extracting results from Deferreds
----------------------------------

When testing code that returns synchronous
:py:class:`~twisted.internet.defer.Deferred`\s for compatibility reasons, you
may want to extract the result directly instead of using matchers.

.. autofunction:: testtools.twistedsupport.extract_result
:noindex:

.. autoexception:: testtools.twistedsupport.DeferredNotFired
:noindex:


Running tests in the reactor
----------------------------

Expand Down
7 changes: 7 additions & 0 deletions testtools/twistedsupport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@
"AsynchronousDeferredRunTest",
"AsynchronousDeferredRunTestForBrokenTwisted",
"CaptureTwistedLogs",
# Deferred utilities
"DeferredNotFired",
"SynchronousDeferredRunTest",
"assert_fails_with",
"extract_result",
"failed",
"flush_logged_errors",
"has_no_result",
# Matchers
"succeeded",
]

from ._deferred import (
DeferredNotFired,
extract_result,
)
from ._matchers import (
failed,
has_no_result,
Expand Down