From 3ad9e7fb1863a8a47d558fe66e3c49896bcc87cc Mon Sep 17 00:00:00 2001 From: tzangms Date: Mon, 21 Mar 2016 02:15:52 +0800 Subject: [PATCH] Add tox --- .gitignore | 3 + .travis.yml | 17 +++- bootstrapform/fixtures/basic_dj16.html | 99 +++++++++++++++++++ bootstrapform/fixtures/basic_old.html | 99 +++++++++++++++++++ bootstrapform/fixtures/horizontal_dj16.html | 102 ++++++++++++++++++++ bootstrapform/fixtures/horizontal_old.html | 102 ++++++++++++++++++++ bootstrapform/tests.py | 24 +++-- setup.py | 4 +- tox.ini | 22 +++++ 9 files changed, 461 insertions(+), 11 deletions(-) create mode 100644 bootstrapform/fixtures/basic_dj16.html create mode 100644 bootstrapform/fixtures/basic_old.html create mode 100644 bootstrapform/fixtures/horizontal_dj16.html create mode 100644 bootstrapform/fixtures/horizontal_old.html create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index a2dd780..10730ca 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ docs/_build /build /dist +.cache +.tox +.python-version diff --git a/.travis.yml b/.travis.yml index 0e1b56a..98bec53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,26 @@ language: python +env: + matrix: + - TOX_ENV=py27-dj15 + - TOX_ENV=py27-dj16 + - TOX_ENV=py27-dj17 + - TOX_ENV=py27-dj18 + - TOX_ENV=py34-dj15 + - TOX_ENV=py34-dj16 + - TOX_ENV=py34-dj17 + - TOX_ENV=py34-dj18 + python: - "2.7" - "3.4" - - "3.5" install: - - pip install coverage coveralls + - pip install tox coverage coveralls script: - - coverage run --source=bootstrapform setup.py test + #- coverage run --source=bootstrapform setup.py test + - tox -e $TOX_ENV after_success: - coveralls diff --git a/bootstrapform/fixtures/basic_dj16.html b/bootstrapform/fixtures/basic_dj16.html new file mode 100644 index 0000000..a2c238e --- /dev/null +++ b/bootstrapform/fixtures/basic_dj16.html @@ -0,0 +1,99 @@ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
    +
  • +
  • +
  • +
+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ +
+
+
diff --git a/bootstrapform/fixtures/basic_old.html b/bootstrapform/fixtures/basic_old.html new file mode 100644 index 0000000..6ef1d14 --- /dev/null +++ b/bootstrapform/fixtures/basic_old.html @@ -0,0 +1,99 @@ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
    +
  • +
  • +
  • +
+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ +
+
+
diff --git a/bootstrapform/fixtures/horizontal_dj16.html b/bootstrapform/fixtures/horizontal_dj16.html new file mode 100644 index 0000000..506d25a --- /dev/null +++ b/bootstrapform/fixtures/horizontal_dj16.html @@ -0,0 +1,102 @@ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+
+ +
+
+ +
+
+ +
+
+
+ +
+ + +
+ +
+
+ +
+ +
+
    +
  • +
  • +
  • +
+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+
+
+ +
+
+
diff --git a/bootstrapform/fixtures/horizontal_old.html b/bootstrapform/fixtures/horizontal_old.html new file mode 100644 index 0000000..fcc1fcd --- /dev/null +++ b/bootstrapform/fixtures/horizontal_old.html @@ -0,0 +1,102 @@ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+
+ +
+
+ +
+
+ +
+
+
+ +
+ + +
+ +
+
+ +
+ +
+
    +
  • +
  • +
  • +
+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+
+
+ +
+
+
diff --git a/bootstrapform/tests.py b/bootstrapform/tests.py index dd9747e..74d8b15 100644 --- a/bootstrapform/tests.py +++ b/bootstrapform/tests.py @@ -1,9 +1,9 @@ import os +from distutils.version import StrictVersion import django from django.test import TestCase from django.template import Template, Context -from django.core.management import call_command from django import forms @@ -37,15 +37,20 @@ class ExampleForm(forms.Form): class BootstrapTemplateTagTests(TestCase): maxDiff = None - def setUp(self): - call_command('migrate', interactive=False) - def test_basic_form(self): form = ExampleForm() html = Template("{% load bootstrap %}{{ form|bootstrap }}").render(Context({'form': form})) - tpl = os.path.join('fixtures', 'basic.html') + + if StrictVersion(django.get_version()) >= StrictVersion('1.7'): + fixture = 'basic.html' + elif StrictVersion(django.get_version()) >= StrictVersion('1.6'): + fixture = 'basic_dj16.html' + else: + fixture = 'basic_old.html' + + tpl = os.path.join('fixtures', fixture) with open(os.path.join(TEST_DIR, tpl)) as f: content = f.read() @@ -56,7 +61,14 @@ class BootstrapTemplateTagTests(TestCase): html = Template("{% load bootstrap %}{{ form|bootstrap_horizontal }}").render(Context({'form': form})) - tpl = os.path.join('fixtures', 'horizontal.html') + if StrictVersion(django.get_version()) >= StrictVersion('1.7'): + fixture = 'horizontal.html' + elif StrictVersion(django.get_version()) >= StrictVersion('1.6'): + fixture = 'horizontal_dj16.html' + else: + fixture = 'horizontal_old.html' + + tpl = os.path.join('fixtures', fixture) with open(os.path.join(TEST_DIR, tpl)) as f: content = f.read() diff --git a/setup.py b/setup.py index 74a79cc..ddd8c43 100644 --- a/setup.py +++ b/setup.py @@ -20,10 +20,10 @@ setup( author='tzangms', author_email='tzangms@gmail.com', url='http://github.com/tzangms/django-bootstrap-form', - license='BSD', + license='MIT', test_suite='runtests.runtests', install_requires = [ - "django>=1.3", + "django>=1.5", ], packages=find_packages(), include_package_data=True, diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..1140769 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +[tox] +envlist = {py27,py34}-django{15,16,17,18} +skipsdist=True + + +[testenv] +basepython = + py27: python2.7 + py34: python3.4 +deps = + pytest + django15: Django>=1.5,<1.6 + django16: Django>=1.6,<1.7 + django17: Django>=1.7,<1.8 + django18: Django>=1.8,<1.9 +commands = python setup.py test + + +[testenv:py27-cov] +deps = + django18: Django>=1.8,<1.9 +command = coverage run --source=bootstrapform setup.py test