summaryrefslogtreecommitdiff
path: root/lib/testtools/doc/for-test-authors.rst
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-10-03 12:20:19 +0200
committerJelmer Vernooij <jelmer@samba.org>2011-10-03 13:54:06 +0200
commitd6c949b0748014587a05d2af1c2b4770d16d68a9 (patch)
treeb0a26d9493eefcc2f5a9c074f93333185334af0f /lib/testtools/doc/for-test-authors.rst
parent1dbcb61c79a0c06fdcfa36bb9304fb0fb66d7ff8 (diff)
downloadsamba-d6c949b0748014587a05d2af1c2b4770d16d68a9.tar.gz
samba-d6c949b0748014587a05d2af1c2b4770d16d68a9.tar.bz2
samba-d6c949b0748014587a05d2af1c2b4770d16d68a9.zip
testtools: Import new upstream snapshot.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Mon Oct 3 13:54:06 CEST 2011 on sn-devel-104
Diffstat (limited to 'lib/testtools/doc/for-test-authors.rst')
-rw-r--r--lib/testtools/doc/for-test-authors.rst12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/testtools/doc/for-test-authors.rst b/lib/testtools/doc/for-test-authors.rst
index eec98b14f8..04c4be6b0d 100644
--- a/lib/testtools/doc/for-test-authors.rst
+++ b/lib/testtools/doc/for-test-authors.rst
@@ -717,7 +717,7 @@ generates. Here's an example mismatch::
self.remainder = remainder
def describe(self):
- return "%s is not divisible by %s, %s remains" % (
+ return "%r is not divisible by %r, %r remains" % (
self.number, self.divider, self.remainder)
def get_details(self):
@@ -738,11 +738,19 @@ in the Matcher itself like this::
remainder = actual % self.divider
if remainder != 0:
return Mismatch(
- "%s is not divisible by %s, %s remains" % (
+ "%r is not divisible by %r, %r remains" % (
actual, self.divider, remainder))
else:
return None
+When writing a ``describe`` method or constructing a ``Mismatch`` object the
+code should ensure it only emits printable unicode. As this output must be
+combined with other text and forwarded for presentation, letting through
+non-ascii bytes of ambiguous encoding or control characters could throw an
+exception or mangle the display. In most cases simply avoiding the ``%s``
+format specifier and using ``%r`` instead will be enough. For examples of
+more complex formatting see the ``testtools.matchers`` implementatons.
+
Details
=======