Nicer links

This commit is contained in:
Jonathan Lange
2016-01-09 12:33:05 +00:00
parent 15f24801f0
commit 5717c09e4f
2 changed files with 19 additions and 17 deletions

View File

@@ -5,18 +5,20 @@ Matching Deferreds
------------------ ------------------
testtools provides support for making assertions about synchronous testtools provides support for making assertions about synchronous
:py:class:`twisted.internet.defer.Deferred`\s. :py:class:`~twisted.internet.defer.Deferred`\s.
A "synchronous" :py:class:`.Deferred` is one that does not need the reactor or A "synchronous" :py:class:`~twisted.internet.defer.Deferred` is one that does
any other asynchronous process in order to fire. not need the reactor or any other asynchronous process in order to fire.
Normal application code can't know when a :py:class:`.Deferred` is going to Normal application code can't know when a
fire, because that is generally left up to the reactor. Well-written unit :py:class:`~twisted.internet.defer.Deferred` is going to fire, because that is
tests provide fake reactors, or don't use the reactor at all, so that generally left up to the reactor. Well-written unit tests provide fake
:py:class:`.Deferred`\s fire synchronously. reactors, or don't use the reactor at all, so that
:py:class:`~twisted.internet.defer.Deferred`\s fire synchronously.
These matchers allow you to make assertions about when and how These matchers allow you to make assertions about when and how
:py:class:`.Deferred`\s fire, and about what values they fire with. :py:class:`~twisted.internet.defer.Deferred`\s fire, and about what values
they fire with.
See also `Testing Deferreds without the reactor`_ and the `Deferred howto`_. See also `Testing Deferreds without the reactor`_ and the `Deferred howto`_.
@@ -32,8 +34,8 @@ Running tests in the reactor
---------------------------- ----------------------------
testtools provides support for running asynchronous Twisted tests: tests that testtools provides support for running asynchronous Twisted tests: tests that
return a :py:class:`.Deferred` and run the reactor until it fires and its return a :py:class:`~twisted.internet.defer.Deferred` and run the reactor
callback chain is completed. until it fires and its callback chain is completed.
Here's how to use it:: Here's how to use it::

View File

@@ -192,8 +192,10 @@ def successful(matcher):
Use this instead of Use this instead of
:py:meth:`twisted.trial.unittest.SynchronousTestCase.successResultOf`. :py:meth:`twisted.trial.unittest.SynchronousTestCase.successResultOf`.
:param matcher: A matcher to match against the result of a Deferred. :param matcher: A matcher to match against the result of a
:return: A matcher that can be applied to a synchronous Deferred. :class:`~twisted.internet.defer.Deferred`.
:return: A matcher that can be applied to a synchronous
:class:`~twisted.internet.defer.Deferred`.
""" """
return _Successful(matcher) return _Successful(matcher)
@@ -252,8 +254,9 @@ def failed(matcher):
:py:meth:`twisted.trial.unittest.SynchronousTestCase.failureResultOf`. :py:meth:`twisted.trial.unittest.SynchronousTestCase.failureResultOf`.
:param matcher: A matcher to match against the result of a failing :param matcher: A matcher to match against the result of a failing
Deferred. :class:`~twisted.internet.defer.Deferred`.
:return: A matcher that can be applied to a synchronous Deferred. :return: A matcher that can be applied to a synchronous
:class:`~twisted.internet.defer.Deferred`.
""" """
return _Failed(matcher) return _Failed(matcher)
@@ -261,8 +264,5 @@ def failed(matcher):
# TODO: Move the non-matcher stuff to _deferred. # TODO: Move the non-matcher stuff to _deferred.
# TODO: Figure out how to just say "Deferred" and get sphinx to link to
# Deferred (i.e. to not have to give fully qualified Python name each time).
# TODO: Fix configuration so that Twisted is included as dependency when we # TODO: Fix configuration so that Twisted is included as dependency when we
# build on rtfd. # build on rtfd.