Commits

Matthew Schinckel  committed b6d9b4c

Add tox support.
Make testing easier.

  • Participants
  • Parent commits 19c4b84

Comments (0)

Files changed (5)

 MANIFEST
 dist/
+.tox

File requirements.txt

+tox
-from distutils.core import setup
-from timedelta import __version__
+import os.path
+from setuptools import setup
 
 setup(
     name = "django-timedeltafield",
-    version = __version__,
+    version = open(os.path.join(os.path.dirname(__file__), 'timedelta', 'VERSION')).read().strip(),
     description = "TimedeltaField for django models",
     long_description = open("README").read(),
     url = "http://hg.schinckel.net/django-timedelta-field/",
         'Operating System :: OS Independent',
         'Framework :: Django',
     ],
+    test_suite='tests.main',
 )
+import os
+import sys
+import unittest
+import doctest
+import django
+
+BASE_PATH = os.path.dirname(__file__) + 'timedelta/'
+
+def main(db_engine='sqlite3'):
+    """
+    Standalone django model test with a 'memory-only-django-installation'.
+    You can play with a django model without a complete django app installation.
+    http://www.djangosnippets.org/snippets/1044/
+    """
+    os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
+    from django.conf import global_settings
+
+    global_settings.INSTALLED_APPS = (
+        'django.contrib.auth',
+        'django.contrib.contenttypes',
+        'timedelta',
+    )
+    global_settings.DATABASES = {
+        'default': {
+            'ENGINE': 'django.db.backends.%s' % db_engine,
+            'NAME': 'django-timedelta',
+        }
+    } 
+
+    global_settings.STATIC_URL = "/static/"
+    global_settings.MEDIA_ROOT = os.path.join(BASE_PATH, 'static')
+    global_settings.STATIC_ROOT = global_settings.MEDIA_ROOT
+    
+    global_settings.SECRET_KEY = '334ebe58-a77d-4321-9d01-a7d2cb8d3eea'
+    
+    from django.test.utils import get_runner
+    test_runner = get_runner(global_settings)
+
+    test_runner = test_runner()
+    failures = test_runner.run_tests(['timedelta'])
+    
+    sys.exit(failures)
+
+def test_postgres():
+    main('postgresql_psycopg2')
+
+if __name__ == '__main__':
+    main()
+[tox]
+envlist = py26,py27,py32,pypy,py27-django-1.4,py27-django-1.5,py27-django-trunk
+[testenv]
+deps=django
+commands= python setup.py test
+[testenv:py27-django-1.4]
+deps= django>=1.4,<1.5
+[testenv:py27-django-1.5]
+deps= django>=1.5,<1.6
+[testenv:py27-django-trunk]
+deps= git+git://github.com/django/django.git