Skip to content

Instantly share code, notes, and snippets.

@aericson
Created February 13, 2017 20:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aericson/e278098b71154e2b6e523b38d63f8f73 to your computer and use it in GitHub Desktop.
Save aericson/e278098b71154e2b6e523b38d63f8f73 to your computer and use it in GitHub Desktop.
Tests with email sending speed boost.
from unittest import mock
class SendsEmailTestCaseMixin(object):
# getfqdn can be too slow, mock it for speed.
# See: https://code.djangoproject.com/ticket/24380
@classmethod
def setUpClass(cls):
cls.getfqdn_patcher = mock.patch(
'django.core.mail.utils.socket.getfqdn',
return_value='vinta.local')
cls.getfqdn_patcher.start()
super().setUpClass()
@classmethod
def tearDownClass(cls):
cls.getfqdn_patcher.stop()
super().tearDownClass()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment