runtests.py 914 B

123456789101112131415161718192021
  1. def runtests():
  2. import atexit, os, shutil, sys
  3. test_runner_path = os.path.dirname(__file__)
  4. project_template_path = os.path.join(
  5. test_runner_path, 'misago/project_template/project_name')
  6. test_project_path = os.path.join(test_runner_path, "testproject")
  7. if not os.path.exists(test_project_path):
  8. shutil.copytree(project_template_path, test_project_path)
  9. settings_path = os.path.join(test_project_path, "settings.py")
  10. with open(settings_path, "r") as py_file:
  11. settings_file = py_file.read().replace("{{ project_name }}",
  12. "testproject")
  13. with open(settings_path, "w") as py_file:
  14. py_file.write(settings_file)
  15. os.environ["DJANGO_SETTINGS_MODULE"] = "testproject.settings"
  16. from django.core.management.commands import test
  17. sys.exit(test.Command().execute(verbosity=1))