testing-cabal / testtools

Testtools - tasteful testing for python
https://testtools.readthedocs.io/en/latest/
Other
95 stars 88 forks source link

Swap Equals order #182

Closed jml closed 8 years ago

jml commented 8 years ago

From https://bugs.launchpad.net/testtools/+bug/1525227:

A test that does this:

self.assertThat('a', Equals('b'))

Will report an error that looks like this:

testtools.matchers._impl.MismatchError: 'b' != 'a'

I would expect it to look like this instead:

testtools.matchers._impl.MismatchError: 'a' != 'b'

So that the order of arguments in the assertion matches the order of values in the error.

This patch makes that change. Some tomfoolery was needed to have the same principle hold for assertEqual which documents expected as its first parameter.

Also deprecates _BinaryMismatch.expected and _BinaryMismatch.observed attributes, which really don't need to be public at all.

Review on Reviewable