Closed wting closed 11 years ago
I saw a suggestion:
assert_that(blah.bla, is_true())
This would allow the user to supply their own truth.
@att14: Truthy.
A user can always be explicit with assert_true(x is True)
.
This is incorrect then.
In [1]: 1 == True
Out[1]: True
In [2]: 'hi' == True
Out[2]: False
In [3]: bool('hi')
Out[3]: True
In [4]: 2 == True
Out[4]: False
In [5]: import testify as T
In [6]: T.assert_equal(2, True)
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-6-a96114e6ec5b> in <module>()
----> 1 T.assert_equal(2, True)
/Library/Python/2.7/site-packages/testify-0.3.8-py2.7.egg/testify/assertions.pyc in assert_equal(lval, rval, message)
239 assert lval == rval, \
240 "assertion failed: l == r\nl: %r\nr: %r\n\n%s" % \
--> 241 (lval, rval, _diff_message(lval, rval))
242
243 assert_equals = assert_equal
AssertionError: assertion failed: l == r
l: 2
r: True
Diff:
l: 2
r: True
In [7]: T.assert_equal(1, True)
Also, I doubt this will be accepted without tests.
Updated. FYI this mimics unittest.assertTrue()
and unittest.assertFalse()
behavior.
ShipIt
Can't automatically merge though so I'm not merging it right now.
Rebased on Yelp/Testify/master, only test failures are catbox related.
There are still (or again) conflicts. :/. I think you're thumb-wrestling with @bukzor, whose changes are more urgent so they get priority.
Rebased off Yelp/Testify/master again.
Whitespace changes are according to Yelp guidelines (2 lines between top level elements, 1 blank line after class definition) for consistency's sake.
assert_equal()
, but the wrong message is printed when the assertion fails.
Adds
assert_true()
andassert_false()
shortcut wrappers.