Created
February 6, 2013 18:18
-
-
Save bootandy/4724593 to your computer and use it in GitHub Desktop.
python. monkey patch a celery method so we can test it
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
class TestEmailer(unittest.TestCase): | |
def setUp(self): | |
super(TestEmailer, self).setUp() | |
self.applied_tasks = [] | |
self.original_celery = celery_jobs.post_url.delay | |
def new_apply_async(*args): | |
self.applied_tasks.append(args) | |
# monkey patch my celery job function | |
celery_jobs.post_url.delay = new_apply_async | |
def tearDown(self): | |
super(TestEmailer, self).tearDown() | |
# Reset the monkey patch to the original method | |
celery_jobs.post_url.delay = self.original_celery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment