summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lange <jml@mumak.net>2016-01-12 19:49:44 +0000
committerJonathan Lange <jml@mumak.net>2016-01-12 19:49:44 +0000
commitbeb752db69633ffdf18b6188cbcca21f070900bd (patch)
treecd82c3efecb5b5165772f62ca1c6f06598b369b7
parentbd163121070454cae255f1259f3628000c007c92 (diff)
downloadtesttools-beb752db69633ffdf18b6188cbcca21f070900bd.tar.gz
Rename `successful` to `succeeded`
-rw-r--r--NEWS2
-rw-r--r--doc/twisted-support.rst2
-rw-r--r--testtools/_deferredmatchers.py15
-rw-r--r--testtools/tests/test_deferredmatchers.py10
-rw-r--r--testtools/twistedsupport.py4
5 files changed, 14 insertions, 19 deletions
diff --git a/NEWS b/NEWS
index b4546e3..9355a4f 100644
--- a/NEWS
+++ b/NEWS
@@ -31,7 +31,7 @@ Improvements
support code in one place, including that currently available under
``testtools.deferredruntest``. (Jonathan Lange)
-* New matchers for testing ``Deferred`` code: ``failed``, ``successful``, and
+* New matchers for testing ``Deferred`` code: ``failed``, ``succeeded``, and
``NO_RESULT``. (Jonathan Lange, Tristan Seligmann, #1369134)
* ``TestCase`` objects can now be run twice. All internal state is reset
diff --git a/doc/twisted-support.rst b/doc/twisted-support.rst
index c212649..cc19d3d 100644
--- a/doc/twisted-support.rst
+++ b/doc/twisted-support.rst
@@ -25,7 +25,7 @@ they fire with.
See also `Testing Deferreds without the reactor`_ and the `Deferred howto`_.
-.. autofunction:: testtools.twistedsupport.successful
+.. autofunction:: testtools.twistedsupport.succeeded
:noindex:
.. autofunction:: testtools.twistedsupport.failed
diff --git a/testtools/_deferredmatchers.py b/testtools/_deferredmatchers.py
index e52c47b..3537b05 100644
--- a/testtools/_deferredmatchers.py
+++ b/testtools/_deferredmatchers.py
@@ -12,11 +12,8 @@ synchronously.
These matchers allow you to make assertions about when and how Deferreds fire,
and about what values they fire with.
-
"""
-# TODO: None of these are published yet. Decide where & how to make them
-# public.
from testtools.compat import _u
from testtools.matchers import Mismatch
@@ -69,11 +66,11 @@ testtools.matchers._impl.MismatchError: No result expected on <Deferred at ... c
"""
-class _Successful(object):
+class _Succeeded(object):
"""Matches a Deferred that has fired successfully."""
def __init__(self, matcher):
- """Construct a ``_Successful`` matcher."""
+ """Construct a ``_Succeeded`` matcher."""
self._matcher = matcher
@staticmethod
@@ -101,13 +98,12 @@ class _Successful(object):
)
-# XXX: The Twisted name is successResultOf. Do we want to use that name?
-def successful(matcher):
+def succeeded(matcher):
"""Match a Deferred that has fired successfully.
For example::
- fires_with_the_answer = successful(Equals(42))
+ fires_with_the_answer = succeeded(Equals(42))
deferred = defer.succeed(42)
assert_that(deferred, fires_with_the_answer)
@@ -123,7 +119,7 @@ def successful(matcher):
:return: A matcher that can be applied to a synchronous
:class:`~twisted.internet.defer.Deferred`.
"""
- return _Successful(matcher)
+ return _Succeeded(matcher)
class _Failed(object):
@@ -158,7 +154,6 @@ class _Failed(object):
)
-# XXX: The Twisted name is failureResultOf. Do we want to use that name?
def failed(matcher):
"""Match a Deferred that has failed.
diff --git a/testtools/tests/test_deferredmatchers.py b/testtools/tests/test_deferredmatchers.py
index 231bbb4..5efd71c 100644
--- a/testtools/tests/test_deferredmatchers.py
+++ b/testtools/tests/test_deferredmatchers.py
@@ -17,7 +17,7 @@ from testtools.tests.test_spinner import NeedsTwistedTestCase
NO_RESULT = try_import('testtools.twistedsupport.NO_RESULT')
failed = try_import('testtools.twistedsupport.failed')
-successful = try_import('testtools.twistedsupport.successful')
+succeeded = try_import('testtools.twistedsupport.succeeded')
defer = try_import('twisted.internet.defer')
@@ -61,7 +61,7 @@ class NoResultTests(NeedsTwistedTestCase):
# A Deferred that hasn't fired matches NO_RESULT.
self.assertThat(self.match(defer.Deferred()), Is(None))
- def test_successful_does_no_match(self):
+ def test_succeeded_does_no_match(self):
# A Deferred that's fired successfully does not match NO_RESULT.
result = object()
deferred = defer.succeed(result)
@@ -109,16 +109,16 @@ class NoResultTests(NeedsTwistedTestCase):
class SuccessResultTests(NeedsTwistedTestCase):
def match(self, matcher, value):
- return successful(matcher).match(value)
+ return succeeded(matcher).match(value)
- def test_successful_result_passes(self):
+ def test_succeeded_result_passes(self):
# A Deferred that has fired successfully matches against the value it
# was fired with.
result = object()
deferred = defer.succeed(result)
self.assertThat(self.match(Is(result), deferred), Is(None))
- def test_different_successful_result_fails(self):
+ def test_different_succeeded_result_fails(self):
# A Deferred that has fired successfully matches against the value it
# was fired with.
result = object()
diff --git a/testtools/twistedsupport.py b/testtools/twistedsupport.py
index f938c7e..0e66cd0 100644
--- a/testtools/twistedsupport.py
+++ b/testtools/twistedsupport.py
@@ -4,7 +4,7 @@
__all__ = [
# Matchers
- 'successful',
+ 'succeeded',
'failed',
'NO_RESULT',
@@ -17,7 +17,7 @@ __all__ = [
]
from ._deferredmatchers import (
- successful,
+ succeeded,
failed,
NO_RESULT,
)