mwilliamson / python-precisely

Matcher library for Python
BSD 2-Clause "Simplified" License
238 stars 11 forks source link

calling and raises assertions #5

Closed danodonovan closed 5 years ago

danodonovan commented 6 years ago

The hamcrest calling and raises exception checking are quite useful. It would be nice if precisely had similar functionality.

I find the hamcrest syntax

assert_that(calling(func).with_args("arg"), raises(Exception))

quite intuitive. Would a direct replication be appropriate?

mwilliamson commented 6 years ago

I'm not a fan of the syntax that Hamcrest uses. Specifically, I'd rather just use a lambda, and pass a matcher rather than exception type:

assert_that(lambda: func("arg"), raises(instance_of(Exception)))
mwilliamson commented 5 years ago

7 has been merged, so I think this can be closed.