Closed danodonovan closed 6 years ago
Hmm, I think including the actual difference is useful, rather than
"more than
I'm on the fence about whether to include the expected value. Either is fine by me, and we can always change it later.
On Wed, 17 Jan 2018 07:57:20 -0800 danodonovan notifications@github.com wrote:
danodonovan commented on this pull request.
@@ -58,3 +58,17 @@ def less_than_or_equal_to_matches_when_actual_is_less_than_or_equal_to_value(): def less_than_or_equal_to_description_describes_value(): matcher = less_than_or_equal_to(42) assert_equal("less than or equal to 42", matcher.describe()) + + +@istest +def close_to_matches_when_actual_is_close_to_value_plus_delta():
- matcher = close_to(42, 1)
- assert_equal(matched(), matcher.match(43))
- assert_equal(matched(), matcher.match(41))
- assert_equal(unmatched("was 40"), matcher.match(40))
Hamcrest have
<40> differed by <2>
Experimenting with
was 40 (differs from 42 by more than 1)
but it is noisier, and not very pleasant for the datetimes
Implements the
close_to
matcher, in a similar way to pyhamcrest. Issue #1