Created
December 12, 2012 13:22
-
-
Save exupero/4267684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
@contextmanager | |
def assert_change_by(fn, delta): | |
original = fn() | |
yield | |
final = fn() | |
assert final - original == delta | |
with assert_change_by(User.objects.count, 1): | |
add_user() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment