[MERGE] TestCase.expectFailure
Robert Collins
robertc at robertcollins.net
Wed Apr 4 01:26:13 BST 2007
On Tue, 2007-04-03 at 19:56 -0400, Martin Pool wrote:
> Martin Pool has voted +1 (conditional).
> Status is now: Conditionally approved
> Comment:
> + def expectFailure(self, reason, test, *args, **kwargs):
> + """Invoke a test, expecting it to fail for the given reason.
> +
> + Intended to be used with a callable that raises AssertionError
> as the
> + test. args and kwargs are passed to the test.
> +
> + Raises KnownFailure if the test fails. Raises AssertionError
> if the
> + test succeeds.
> +
>
> I would expect that a parameter called 'test' took a test object. The
> example makes it clear that you're actually meant to pass a callable
> assertion. You could also add a note in this docstring that this is for
> things that _should_ pass, but that are not fixed yet, as opposed to
> assertRaises where it really _should_ fail.
I'm not sure this meets the intention of ExpectedFailure - the idea is
that we would check for the precise failure that is occuring.
As an example of how this is not precise:
self.expectFailure('foo', self.assertEqual, 1, dynamic_value)
This will raise expected failure whenever dynamic_value is not 1, but in
fact we may only be sure that its failing in the *known manner* when
dynamic_value is '54'.
So I'd rather see this example written as:
...
if dynamic_value == 54:
self.known_failure('the hashcache counts unversioned files in its
total')
self.assertEqual(1, dynamic_value)
...
I'm very pro helper functions that preserve that precision - but I dont
think this particular one does.
-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070404/b38bacc1/attachment-0001.pgp
More information about the bazaar
mailing list