From 87e2201b64cd1a7499aefe244a30d8b75e756e4e Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Wed, 21 Sep 2016 22:54:41 +0200 Subject: [PATCH] Fix travis config and add tox (cherry picked from commit 3126b4e1465262ea34fb06bede4b0ec13052f33a) --- .travis.yml | 20 +++++++++--------- tox.ini | 27 +++++++++++++++++++++++++ wagtail_modeltranslation/tests/tests.py | 18 ++++++++--------- 3 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index ab471d2..8ef4027 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,14 @@ language: "python" python: - "2.7" - - "3.2" - - "3.3" - - "3.4" - - "3.5" +cache: pip +install: travis_retry pip install "virtualenv<14.0.0" tox +script: tox -e $TOX_ENV env: - - DJANGO=1.8, DB=sqlite - - DJANGO=1.8, DB=postgres - - DJANGO=1.8, DB=mysql - - DJANGO=1.9, DB=sqlite - - DJANGO=1.9, DB=postgres - - DJANGO=1.9, DB=mysql + - TOX_ENV=django18-py27, DB=sqlite + - TOX_ENV=django18-py27, DB=postgres + - TOX_ENV=django18-py27, DB=mysql + - TOX_ENV=django19-py27, DB=sqlite + - TOX_ENV=django19-py27, DB=postgres + - TOX_ENV=django19-py27, DB=mysql +script: tox -e $TOX_ENV diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..92bb242 --- /dev/null +++ b/tox.ini @@ -0,0 +1,27 @@ +[tox] +envlist = + django18-py{27} + +[testenv] +deps = + django18: {[django]1.8.x} + django19: {[django]1.9.x} + wagtail>=1.6,<1.7 + +commands = ./runtests.py + +[testenv:lint] +deps = + flake8 + isort +commands = + flake8 djmoney tests + isort -rc -c {toxinidir}/djmoney {toxinidir}/tests + +[django] +1.8.x = + Django>=1.8.0,<1.9.0 +1.9.x = + Django>=1.9.0,<1.10.0 +1.10.x = + Django>=1.10.0,<1.11.0 diff --git a/wagtail_modeltranslation/tests/tests.py b/wagtail_modeltranslation/tests/tests.py index e0bd5a4..482d149 100755 --- a/wagtail_modeltranslation/tests/tests.py +++ b/wagtail_modeltranslation/tests/tests.py @@ -2,6 +2,8 @@ import datetime import imp import shutil +import unittest + from decimal import Decimal import django @@ -130,15 +132,6 @@ class ModeltranslationTransactionTestBase(TransactionTestCase): from wagtail_modeltranslation.models import handle_translation_registrations handle_translation_registrations() - # 5. makemigrations - from django.db import connections, DEFAULT_DB_ALIAS - call_command('makemigrations', verbosity=2, interactive=False, - database=connections[DEFAULT_DB_ALIAS].alias) - - # 6. Syncdb - call_command('migrate', verbosity=0, migrate=False, interactive=False, run_syncdb=True, - database=connections[DEFAULT_DB_ALIAS].alias, load_initial_data=False) - # A rather dirty trick to import models into module namespace, but not before # tests app has been added into INSTALLED_APPS and loaded # (that's why this is not imported in normal import section) @@ -147,6 +140,12 @@ class ModeltranslationTransactionTestBase(TransactionTestCase): models = t_models translation = t_translation + from django.db import connections, DEFAULT_DB_ALIAS + # 6. Syncdb + call_command('migrate', verbosity=0, migrate=False, interactive=False, run_syncdb=True, + database=connections[DEFAULT_DB_ALIAS].alias, load_initial_data=False) + + def setUp(self): self._old_language = get_language() trans_real.activate('de') @@ -2172,6 +2171,7 @@ class ModelInheritanceFieldAggregationTest(ModeltranslationTestBase): class UpdateCommandTest(ModeltranslationTestBase): + @unittest.skipIf('tox' in os.environ.get('VIRTUAL_ENV', ""), 'running the below command is no good in Tox') def test_update_command(self): # Here it would be convenient to use fixtures - unfortunately, # fixtures loader doesn't use raw sql but rather creates objects,