mirror of
https://github.com/Hopiu/django-markdownx.git
synced 2026-04-28 00:44:42 +00:00
Travis
This commit is contained in:
parent
70f3fa45c1
commit
8a2928249b
3 changed files with 41 additions and 66 deletions
|
|
@ -9,4 +9,5 @@ install:
|
|||
env:
|
||||
- DJANGO_VERSION=1.7
|
||||
- DJANGO_VERSION=1.8
|
||||
script: python quicktest.py markdownx
|
||||
script: python runtests.py
|
||||
sudo: false
|
||||
|
|
|
|||
65
quicktest.py
65
quicktest.py
|
|
@ -1,65 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from django.conf import settings
|
||||
|
||||
class QuickDjangoTest(object):
|
||||
"""
|
||||
A quick way to run the Django test suite without a fully-configured project.
|
||||
|
||||
Example usage:
|
||||
|
||||
>>> QuickDjangoTest('app1', 'app2')
|
||||
|
||||
Based on a script published by Lukasz Dziedzia at:
|
||||
http://stackoverflow.com/questions/3841725/how-to-launch-tests-for-django-reusable-app
|
||||
"""
|
||||
DIRNAME = os.path.dirname(__file__)
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.admin',
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.apps = args
|
||||
self.run_tests()
|
||||
|
||||
|
||||
def run_tests(self):
|
||||
settings.configure(
|
||||
DEBUG = False,
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(self.DIRNAME, 'database.db'),
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
'HOST': '',
|
||||
'PORT': '',
|
||||
}
|
||||
},
|
||||
INSTALLED_APPS = self.INSTALLED_APPS + self.apps
|
||||
)
|
||||
from django.test.simple import DjangoTestSuiteRunner
|
||||
failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1, interactive=False)
|
||||
if failures:
|
||||
sys.exit(failures)
|
||||
|
||||
if __name__ == '__main__':
|
||||
"""
|
||||
What do when the user hits this file from the shell.
|
||||
|
||||
Example usage:
|
||||
|
||||
$ python quicktest.py app1 app2
|
||||
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="[args]",
|
||||
description="Run Django tests on the provided applications."
|
||||
)
|
||||
parser.add_argument('apps', nargs='+', type=str)
|
||||
args = parser.parse_args()
|
||||
QuickDjangoTest(*args.apps)
|
||||
39
runtests.py
Normal file
39
runtests.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), 'markdownx'))
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
|
||||
configure_settings = {
|
||||
'DATABASES': {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': ':memory:',
|
||||
}
|
||||
},
|
||||
'INSTALLED_APPS': [
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.staticfiles',
|
||||
'markdownx',
|
||||
],
|
||||
'DEBUG': False,
|
||||
}
|
||||
|
||||
settings.configure(**configure_settings)
|
||||
|
||||
from django.test.utils import get_runner
|
||||
if django.VERSION >= (1, 7):
|
||||
django.setup()
|
||||
|
||||
test_runner = get_runner(settings)
|
||||
failures = test_runner(
|
||||
verbosity=1,
|
||||
interactive=False,
|
||||
failfast=False).run_tests(['tests'])
|
||||
sys.exit(failures)
|
||||
Loading…
Reference in a new issue