-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mixin and Runner for use with django.test.TestCase
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import sms | ||
|
||
|
||
class SMSTestCaseMixin: | ||
"""A TestCase mixin that sets up the fake sms backend like Django sets | ||
up the fake email backend | ||
""" | ||
def _pre_setup(self): | ||
super()._pre_setup() | ||
sms.outbox = [] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import sms | ||
from django.conf import settings | ||
from django.test.runner import DiscoverRunner | ||
|
||
|
||
class SMSTestRunner(DiscoverRunner): | ||
"""A test runner that sets up the fake sms backend like Django sets | ||
up the fake email backend | ||
""" | ||
def setup_test_environment(self, **kwargs): | ||
settings.SMS_BACKEND = "sms.backends.locmem.SmsBackend" | ||
sms.outbox = [] | ||
super().setup_test_environment(**kwargs) |