exam icon indicating copy to clipboard operation
exam copied to clipboard

Usage of `assertDoesNotChange` with `before` or `after` parameters results in confusing error message.

Open tkaemming opened this issue 10 years ago • 0 comments

Any combination of usage of before or after parameters results in an error, for example:

Traceback (most recent call last):
  File "example.py", line 10, in test_assertdoesnotchange_after
    with self.assertDoesNotChange(lambda: 0, before=0):
  File "/Users/ted/.virtualenvs/eaxm/lib/python2.7/site-packages/exam/asserts.py", line 33, in __enter__
    assert not check, message.format(**vars(self))
AssertionError: Value before is 0, not 0

This prevents being able to use the before or after keyword (or both) as a shorter form of the assertion:

value = 0
with self.assertDoesNotChange(lambda: value):
  assert value == 0

tkaemming avatar Sep 23 '15 22:09 tkaemming