diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-11-14 09:46:53 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-11-14 09:46:53 +0100 |
commit | 7b654a8c180a6467147189332916a5e56634b5af (patch) | |
tree | 20f9f47eab9f15a425b8dfeb4ad08c1e7021808a /lib/testtools/doc/for-test-authors.rst | |
parent | d10c7378d96d322910e87c21a1a3a3b28b229687 (diff) | |
download | samba-7b654a8c180a6467147189332916a5e56634b5af.tar.gz samba-7b654a8c180a6467147189332916a5e56634b5af.tar.bz2 samba-7b654a8c180a6467147189332916a5e56634b5af.zip |
testtools: Update to latest version.
Diffstat (limited to 'lib/testtools/doc/for-test-authors.rst')
-rw-r--r-- | lib/testtools/doc/for-test-authors.rst | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/testtools/doc/for-test-authors.rst b/lib/testtools/doc/for-test-authors.rst index febbb84151..b83221bd5d 100644 --- a/lib/testtools/doc/for-test-authors.rst +++ b/lib/testtools/doc/for-test-authors.rst @@ -1322,6 +1322,27 @@ Safe attribute testing particular attribute. +Nullary callables +----------------- + +Sometimes you want to be able to pass around a function with the arguments +already specified. The normal way of doing this in Python is:: + + nullary = lambda: f(*args, **kwargs) + nullary() + +Which is mostly good enough, but loses a bit of debugging information. If you +take the ``repr()`` of ``nullary``, you're only told that it's a lambda, and +you get none of the juicy meaning that you'd get from the ``repr()`` of ``f``. + +The solution is to use ``Nullary`` instead:: + + nullary = Nullary(f, *args, **kwargs) + nullary() + +Here, ``repr(nullary)`` will be the same as ``repr(f)``. + + .. _testrepository: https://launchpad.net/testrepository .. _Trial: http://twistedmatrix.com/documents/current/core/howto/testing.html .. _nose: http://somethingaboutorange.com/mrl/projects/nose/ |