Skip to content

Commit

Permalink
Merge pull request #80 from johnpaulett/execute-from-command-line-tes…
Browse files Browse the repository at this point in the history
…t-entry

Convert test.py to use the Django 1.4+ execute_from_command_line.

(Merging it so that I can test it with the new travis-based testing-multiple-versions setup I just cooked up)
  • Loading branch information
reinout committed Oct 28, 2013
2 parents 764f519 + 9fe9bbb commit 1fcd8cf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/djangorecipe/test.py
@@ -1,7 +1,10 @@
import os

import django
from django.core import management


def main(settings_file, *apps):
def main_pre_14(settings_file, *apps):
argv = ['test', 'test'] + list(apps)
try:
settings = __import__(settings_file)
Expand All @@ -17,3 +20,16 @@ def main(settings_file, *apps):
sys.exit(1)

management.execute_manager(settings, argv=argv)


def main_14(settings_file, *apps):
argv = ['test', 'test'] + list(apps)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings_file)
management.execute_from_command_line(argv)


def main(settings_file, *apps):
if django.VERSION[0:2] >= (1, 4):
main_14(settings_file, *apps)
else:
main_pre_14(settings_file, *apps)

0 comments on commit 1fcd8cf

Please sign in to comment.