From a5a235649500ac0d7a035f3bf206b912ead1c78f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 6 Sep 2013 15:02:19 +0200 Subject: [PATCH] setup.py: add command to run tests also add url and settings file for running the tests --- setup.py | 26 ++++++++++++++++++++++++-- test_settings.py | 5 +++++ test_urls.py | 0 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 test_settings.py create mode 100644 test_urls.py diff --git a/setup.py b/setup.py index 51ac6b8..e9510cf 100755 --- a/setup.py +++ b/setup.py @@ -7,6 +7,27 @@ from distutils.command.build import build as _build from distutils.command.sdist import sdist as _sdist from distutils.cmd import Command +class test(Command): + description = 'run django tests' + user_options = [] + + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + import os + try: + from django.core.management import call_command + except ImportError: + raise RuntimeError('You need django in your PYTHONPATH') + os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings' + call_command('test', 'django_journal') + + class compile_translations(Command): description = 'compile message catalogs to MO files via django compilemessages' user_options = [] @@ -83,10 +104,11 @@ setup(name='django-journal', include_package_data=True, cmdclass={'build': build, 'install_lib': install_lib, 'compile_translations': compile_translations, - 'sdist': sdist}, + 'sdist': sdist, + 'test': test}, install_requires=[ 'django >= 1.4.2', - 'django-model-utils<1.4', + 'django-model-utils', ], setup_requires=[ 'django >= 1.4.2', diff --git a/test_settings.py b/test_settings.py new file mode 100644 index 0000000..fa94ae7 --- /dev/null +++ b/test_settings.py @@ -0,0 +1,5 @@ +INSTALLED_APPS = ('django_journal', 'django.contrib.contenttypes' , 'django.contrib.auth', 'django.contrib.sessions', ) +DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3' }, } +SECRET_KEY = "django_tests_secret_key" +PASSWORD_HASHERS = ( 'django.contrib.auth.hashers.MD5PasswordHasher',) +ROOT_URLCONF = 'test_urls' diff --git a/test_urls.py b/test_urls.py new file mode 100644 index 0000000..e69de29