Yelp / Testify

A more pythonic testing framework.
Other
308 stars 67 forks source link

assert_raises_such_that should assert that the lambda's evaluation is None or is True #214

Closed asottile closed 4 years ago

asottile commented 10 years ago
import testify as T

class Regression(T.TestCase):

    # XXX: if I had an expected failure decorator I'd use it here
    def test(self):
        T.assert_raises_such_that(ValueError, lambda e: e.args == ('foo',)):
            raise ValueError('bar')
bukzor commented 10 years ago

There's prior art in our assertions.wait_for that does what anthony expects:

            result = assertion()
            if result is not None:
                # A value was returned. Was it truthy?
                assert result, 'Not truthy: %r' % result
bukzor commented 10 years ago

@asottile This should be a quick fix for you some day when you have downtime.