testing.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # GNU MediaGoblin -- federated, autonomous media hosting
  2. # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. from mediagoblin.tools import common
  17. from mediagoblin.tools.template import clear_test_template_context
  18. from mediagoblin.tools.mail import EMAIL_TEST_INBOX, EMAIL_TEST_MBOX_INBOX
  19. def _activate_testing():
  20. """
  21. Call this to activate testing in util.py
  22. """
  23. common.TESTS_ENABLED = True
  24. def clear_test_buckets():
  25. """
  26. We store some things for testing purposes that should be cleared
  27. when we want a "clean slate" of information for our next round of
  28. tests. Call this function to wipe all that stuff clean.
  29. Also wipes out some other things we might redefine during testing,
  30. like the jinja envs.
  31. """
  32. global SETUP_JINJA_ENVS
  33. SETUP_JINJA_ENVS = {}
  34. global EMAIL_TEST_INBOX
  35. global EMAIL_TEST_MBOX_INBOX
  36. EMAIL_TEST_INBOX = []
  37. EMAIL_TEST_MBOX_INBOX = []
  38. clear_test_template_context()