|
| 1 | +import django |
| 2 | +import sys |
| 3 | +import os |
| 4 | +from django.conf import settings |
| 5 | + |
| 6 | +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 7 | + |
| 8 | +settings.configure( |
| 9 | + DEBUG=True, |
| 10 | + DATABASES={ |
| 11 | + 'default': { |
| 12 | + 'NAME': ':memory:', |
| 13 | + 'ENGINE': 'django.db.backends.sqlite3', |
| 14 | + } |
| 15 | + }, |
| 16 | + TEMPLATES=[{ |
| 17 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 18 | + 'DIRS': [ |
| 19 | + os.path.join(BASE_DIR, 'django-markdown-editor/martor/templates'), |
| 20 | + os.path.join(BASE_DIR, 'django-markdown-editor/martor/tests/templates'), |
| 21 | + ], |
| 22 | + 'APP_DIRS': True, |
| 23 | + 'OPTIONS': { |
| 24 | + 'context_processors': [ |
| 25 | + 'django.template.context_processors.debug', |
| 26 | + 'django.template.context_processors.request', |
| 27 | + 'django.contrib.auth.context_processors.auth', |
| 28 | + 'django.contrib.messages.context_processors.messages', |
| 29 | + ], |
| 30 | + }, |
| 31 | + }], |
| 32 | + ROOT_URLCONF='martor.tests.urls', |
| 33 | + INSTALLED_APPS=['django.contrib.auth', |
| 34 | + 'django.contrib.contenttypes', |
| 35 | + 'django.contrib.sessions', |
| 36 | + 'django.contrib.admin', |
| 37 | + 'martor']) |
| 38 | + |
| 39 | +try: |
| 40 | + # Django <= 1.8 |
| 41 | + from django.test.simple import DjangoTestSuiteRunner |
| 42 | + test_runner = DjangoTestSuiteRunner(verbosity=1) |
| 43 | +except ImportError: |
| 44 | + # Django >= 1.8 |
| 45 | + django.setup() |
| 46 | + from django.test.runner import DiscoverRunner |
| 47 | + test_runner = DiscoverRunner(verbosity=1) |
| 48 | + |
| 49 | +failures = test_runner.run_tests(['martor']) |
| 50 | +if failures: |
| 51 | + sys.exit(failures) |
0 commit comments