Expected failure not failing when assertion succeeds

John Arbash Meinel john at arbash-meinel.com
Tue Feb 16 21:07:13 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

We currently have a change in semantics for 'expectedFailure', I assume
it is a result of the testtools switch.

Specifically I would expect this test to fail:

    def test_expected_failure(self):
        self.expectFailure("expect failure but find success",
            self.assertEqual, 1, 1)

However this succeeds without complaint.

Now I did track down this code in testtools:
    def addUnexpectedSuccess(self, test, details=None):
        outcome = getattr(self.decorated, 'addUnexpectedSuccess', None)
        if outcome is None:
            return self.decorated.addSuccess(test)
        if details is not None:
            try:
                return outcome(test, details=details)
            except TypeError:
                pass
        return outcome(test)


Which seems to try to call 'addUnexpectedSuccess' to its child, and if
it doesn't have it, then it just calls 'addSuccess'. So it is possible
that we just need to implement 'addUnexpectedSuccess'.

On the other hand, shouldn't an unexpected success default to being
treated as a failure (addFailure() rather than addSuccess)?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkt7CQEACgkQJdeBCYSNAAM2dACgppA7IZUDDMVIQV9tdTv53z9n
EBEAnjcSuqnH/Lxzfgjp8Sq3BOHMM/1F
=fslp
-----END PGP SIGNATURE-----



More information about the bazaar mailing list