What's the best way to tell (from regular code) if we're in a test? I have added extra authentication steps (security questions) that would be difficult to deal with in tests where you just want to run self.client.login() or post to the login URL. I've noticed that several third party modules, such as django-digest and django-bcrypt, also disable parts of their functionality during testing like this:
from django.core import mail
if hasattr(mail, 'outbox'):
# we are under a test
else:
# not under a test
This works, but it's an undocumented side effect so I'm worried it might change in a future version. What's the correct way to tell if we're in a test?
Thanks,
Jody
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment