From 36015c8ed0aedaa8bca0e7a740f585a6cf82b4d9 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Tue, 22 Mar 2011 15:17:10 +0000 Subject: [PATCH] Clean up errors. --- testtools/_spinner.py | 6 +++--- testtools/deferredruntest.py | 7 ++++--- testtools/runtest.py | 4 ++-- testtools/testcase.py | 20 ++++++++++---------- testtools/tests/test_testresult.py | 6 +++--- testtools/tests/test_testtools.py | 2 +- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/testtools/_spinner.py b/testtools/_spinner.py index 23f924e..baf455a 100644 --- a/testtools/_spinner.py +++ b/testtools/_spinner.py @@ -215,9 +215,9 @@ class Spinner(object): """Clean up any junk in the reactor. Will always iterate the reactor a number of times equal to - `Spinner._OBLIGATORY_REACTOR_ITERATIONS`. This is to work around bugs - in various Twisted APIs where a Deferred fires but still leaves work - (e.g. cancelling a call, actually closing a connection) for the + ``Spinner._OBLIGATORY_REACTOR_ITERATIONS``. This is to work around + bugs in various Twisted APIs where a Deferred fires but still leaves + work (e.g. cancelling a call, actually closing a connection) for the reactor to do. """ for i in range(self._OBLIGATORY_REACTOR_ITERATIONS): diff --git a/testtools/deferredruntest.py b/testtools/deferredruntest.py index 005986c..996e113 100644 --- a/testtools/deferredruntest.py +++ b/testtools/deferredruntest.py @@ -98,7 +98,7 @@ class AsynchronousDeferredRunTest(_DeferredRunTest): :param case: The `TestCase` to run. :param handlers: A list of exception handlers (ExceptionType, handler) where 'handler' is a callable that takes a `TestCase`, a - `testtools.TestResult` and the exception raised. + ``testtools.TestResult`` and the exception raised. :param reactor: The Twisted reactor to use. If not given, we use the default reactor. :param timeout: The maximum time allowed for running a test. The @@ -292,8 +292,9 @@ def assert_fails_with(d, *exc_types, **kwargs): :param exc_types: The exception types that the Deferred is expected to fail with. :param failureException: An optional keyword argument. If provided, will - raise that exception instead of `testtools.TestCase.failureException`. - :return: A Deferred that will fail with an `AssertionError` if 'd' does + raise that exception instead of + ``testtools.TestCase.failureException``. + :return: A Deferred that will fail with an ``AssertionError`` if 'd' does not fail with one of the exception types. """ failureException = kwargs.pop('failureException', None) diff --git a/testtools/runtest.py b/testtools/runtest.py index 7f6eb5c..6097911 100644 --- a/testtools/runtest.py +++ b/testtools/runtest.py @@ -145,7 +145,7 @@ class RunTest(object): See the docstring for addCleanup for more information. :return: None if all cleanups ran without error, - `exception_caught` if there was an error. + ``exception_caught`` if there was an error. """ failing = False while self.case._cleanups: @@ -162,7 +162,7 @@ class RunTest(object): Exceptions are processed by `_got_user_exception`. - :return: Either whatever 'fn' returns or `exception_caught` if + :return: Either whatever 'fn' returns or ``exception_caught`` if 'fn' raised an exception. """ try: diff --git a/testtools/testcase.py b/testtools/testcase.py index f557726..d12a22a 100644 --- a/testtools/testcase.py +++ b/testtools/testcase.py @@ -65,7 +65,7 @@ _ExpectedFailure = try_import( def run_test_with(test_runner, **kwargs): - """Decorate a test as using a specific `RunTest`. + """Decorate a test as using a specific ``RunTest``. e.g. .. python:: @@ -75,16 +75,16 @@ def run_test_with(test_runner, **kwargs): self.assertTrue(True) The returned decorator works by setting an attribute on the decorated - function. `TestCase.__init__` looks for this attribute when deciding - on a `RunTest` factory. If you wish to use multiple decorators on a test - method, then you must either make this one the top-most decorator, or - you must write your decorators so that they update the wrapping function - with the attributes of the wrapped function. The latter is recommended - style anyway. 'functools.wraps', 'functools.wrapper' and + function. `TestCase.__init__` looks for this attribute when deciding on a + ``RunTest`` factory. If you wish to use multiple decorators on a test + method, then you must either make this one the top-most decorator, or you + must write your decorators so that they update the wrapping function with + the attributes of the wrapped function. The latter is recommended style + anyway. 'functools.wraps', 'functools.wrapper' and 'twisted.python.util.mergeFunctionMetadata' can help you do this. - :param test_runner: A `RunTest` factory that takes a test case and an - optional list of exception handlers. See `RunTest`. + :param test_runner: A ``RunTest`` factory that takes a test case and an + optional list of exception handlers. See ``RunTest``. :param kwargs: Keyword arguments to pass on as extra arguments to 'test_runner'. :return: A decorator to be used for marking a test as needing a special @@ -122,7 +122,7 @@ class TestCase(unittest.TestCase): :keyword runTest: Optional class to use to execute the test. If not supplied `RunTest` is used. The instance to be used is created when run() is invoked, so will be fresh each time. Overrides - `TestCase.run_tests_with` if given. + ``TestCase.run_tests_with`` if given. """ runTest = kwargs.pop('runTest', None) unittest.TestCase.__init__(self, *args, **kwargs) diff --git a/testtools/tests/test_testresult.py b/testtools/tests/test_testresult.py index 943ea85..a35d8e7 100644 --- a/testtools/tests/test_testresult.py +++ b/testtools/tests/test_testresult.py @@ -277,7 +277,7 @@ class TestAdaptedPython27TestResultContract(TestCase, DetailsContract): class TestTestResult(TestCase): - """Tests for `TestResult`.""" + """Tests for 'TestResult'.""" def makeResult(self): """Make an arbitrary result for testing.""" @@ -339,7 +339,7 @@ class TestWithFakeExceptions(TestCase): class TestMultiTestResult(TestWithFakeExceptions): - """Tests for `MultiTestResult`.""" + """Tests for 'MultiTestResult'.""" def setUp(self): TestWithFakeExceptions.setUp(self) @@ -432,7 +432,7 @@ class TestMultiTestResult(TestWithFakeExceptions): class TestTextTestResult(TestCase): - """Tests for `TextTestResult`.""" + """Tests for 'TextTestResult'.""" def setUp(self): super(TestTextTestResult, self).setUp() diff --git a/testtools/tests/test_testtools.py b/testtools/tests/test_testtools.py index c5c26f9..d5ac129 100644 --- a/testtools/tests/test_testtools.py +++ b/testtools/tests/test_testtools.py @@ -200,7 +200,7 @@ class TestErrorHolder(TestCase): class TestEquality(TestCase): - """Test `TestCase`'s equality implementation.""" + """Test ``TestCase``'s equality implementation.""" def test_identicalIsEqual(self): # TestCase's are equal if they are identical.