[issue20798] Reversed order in testtools messages

Pete Zaitcev report at bugs.python.org
Thu Feb 27 17:40:42 CET 2014


New submission from Pete Zaitcev:

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:
 https://bugs.launchpad.net/ceilometer/+bug/1277104

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 at guren xxx]$ python3 -c 'import nose; nose.main()'
F
======================================================================
FAIL: testic.TestConfigTrueValue.test_testEquals
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/q/zaitcev/tmp/xxx/testic.py", line 10, in test_testEquals
    self.assertEquals(function_under_test(), reference)
  File "/usr/lib/python3.3/site-packages/testtools/testcase.py", line 322, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/usr/lib/python3.3/site-packages/testtools/testcase.py", line 417, in assertThat
    raise MismatchError(matchee, matcher, mismatch, verbose)
testtools.matchers._impl.MismatchError: !=:
reference = 'actual-0123456789012345678901234567890123456789'
actual    = 'reference-0123456789012345678901234567890123456789'

----------
components: Library (Lib)
messages: 212366
nosy: zaitcev
priority: normal
severity: normal
status: open
title: Reversed order in testtools messages
type: behavior
versions: Python 2.7, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20798>
_______________________________________


More information about the Python-bugs-list mailing list