This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Reversed order in testtools messages
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3, Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: r.david.murray, zaitcev
Priority: normal Keywords:

Created on 2014-02-27 16:40 by zaitcev, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg212366 - (view) Author: Pete Zaitcev (zaitcev) Date: 2014-02-27 16:40
When using an assert such as self.assertEquals(tester(), expected), an error message suggests wrong argument order (as in, not the order in examples in the documentation). Apparently this is confusing enough that OpenStack even opened a whole bunch of bugs and filed patches to swap the order in the tests:

If the code is:

import testtools

class TestConfigTrueValue(testtools.TestCase):
    def test_testEquals(self):
        reference = "reference-0123456789012345678901234567890123456789"
        def function_under_test():
            return "actual-0123456789012345678901234567890123456789"
        self.assertEquals(function_under_test(), reference)

then running it yields

[zaitcev@guren xxx]$ python3 -c 'import nose; nose.main()'
FAIL: testic.TestConfigTrueValue.test_testEquals
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/q/zaitcev/tmp/xxx/", line 10, in test_testEquals
    self.assertEquals(function_under_test(), reference)
  File "/usr/lib/python3.3/site-packages/testtools/", line 322, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/usr/lib/python3.3/site-packages/testtools/", line 417, in assertThat
    raise MismatchError(matchee, matcher, mismatch, verbose)
testtools.matchers._impl.MismatchError: !=:
reference = 'actual-0123456789012345678901234567890123456789'
actual    = 'reference-0123456789012345678901234567890123456789'
msg212368 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-02-27 16:51
Testtools is not part of the stdlib.  Are you saying there is a bug in the stdlib assertEqual?  If so, can you demonstrate the bug using just stdlib-based code?
msg212379 - (view) Author: Pete Zaitcev (zaitcev) Date: 2014-02-27 19:46
Oh, indeed. The printout is in testtools only. The unittest prints this:

[zaitcev@guren xxx]$ python3 -c 'import nose; nose.main()'
FAIL: test_testEquals (testic.TestConfigTrueValue)
Traceback (most recent call last):
  File "/q/zaitcev/tmp/xxx/", line 11, in test_testEquals
    self.assertEquals(function_under_test(), reference)
AssertionError: 'actual-0123456789012345678901234567890123456789' != 'reference-0123456789012345678901234567890123456789'
- actual-0123456789012345678901234567890123456789
? ^ ^^^^
+ reference-0123456789012345678901234567890123456789
? ^^^^^^^ ^

Sorry, closing the issue as invalid.
Date User Action Args
2022-04-11 14:57:59adminsetgithub: 64997
2014-02-27 19:58:02r.david.murraysetstatus: open -> closed
2014-02-27 19:46:12zaitcevsetresolution: not a bug
messages: + msg212379
2014-02-27 16:51:31r.david.murraysetnosy: + r.david.murray
messages: + msg212368
2014-02-27 16:40:42zaitcevcreate