From 48c174a23219520910869828964733591299a612 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 15 Feb 2015 13:48:14 +0100 Subject: [PATCH] Modernize test setup. --- .coveragerc | 6 +++ .gitignore | 3 +- .travis.yml | 64 ++++++++++++---------------- requirements/tests.txt | 3 -- setup.py | 9 +--- {appconf/tests => tests}/__init__.py | 0 {appconf/tests => tests}/models.py | 2 +- {appconf/tests => tests}/settings.py | 0 {appconf => tests}/test_settings.py | 2 +- {appconf/tests => tests}/tests.py | 10 ++--- tox.ini | 50 ++++++++++++++++++++++ 11 files changed, 95 insertions(+), 54 deletions(-) create mode 100644 .coveragerc delete mode 100644 requirements/tests.txt rename {appconf/tests => tests}/__init__.py (100%) rename {appconf/tests => tests}/models.py (95%) rename {appconf/tests => tests}/settings.py (100%) rename {appconf => tests}/test_settings.py (94%) rename {appconf/tests => tests}/tests.py (93%) create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..2884516 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[run] +source = appconf +branch = 1 + +[report] +omit = *tests* diff --git a/.gitignore b/.gitignore index da377c9..0187a2e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ MANIFEST *.egg-info *.egg docs/_build/ -.coverage \ No newline at end of file +.coverage +.tox/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5a2cd32..726bab6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,30 @@ language: python -python: - - "2.6" - - "2.7" - - "3.2" - - "3.3" -before_install: - - export DJANGO_SETTINGS_MODULE=appconf.test_settings -install: - - pip install -e . - - pip install https://github.com/django/django/archive/${DJANGO}.zip#egg=django - - pip install -r requirements/tests.txt -before_script: - - flake8 appconf --ignore=E501 -script: - - coverage run --branch --source=appconf `which django-admin.py` test appconf - - coverage report --omit=appconf/test* env: - - DJANGO=1.3.7 - - DJANGO=1.4.5 - - DJANGO=1.5.1 - - DJANGO=1.7.4 - - DJANGO=master - -matrix: - exclude: - - python: "3.2" - env: DJANGO=1.3.7 - - python: "3.2" - env: DJANGO=1.4.5 - - python: "3.3" - env: DJANGO=1.3.7 - - python: "3.3" - env: DJANGO=1.4.5 - - python: "2.6" - env: DJANGO=1.7.4 - - python: "2.6" - env: DJANGO=master + - TOXENV=flake8-py27 + - TOXENV=flake8-py33 + - TOXENV=py26-dj14 + - TOXENV=py27-dj14 + - TOXENV=py26-dj15 + - TOXENV=py26-dj16 + - TOXENV=py27-dj15 + - TOXENV=py27-dj16 + - TOXENV=py32-dj15 + - TOXENV=py32-dj16 + - TOXENV=py33-dj15 + - TOXENV=py33-dj16 + - TOXENV=py27-dj17 + - TOXENV=py27-dj18 + - TOXENV=py27-dj19 + - TOXENV=py32-dj17 + - TOXENV=py32-dj18 + - TOXENV=py32-dj19 + - TOXENV=py33-dj17 + - TOXENV=py33-dj18 + - TOXENV=py33-dj19 + - TOXENV=py34-dj17 + - TOXENV=py34-dj18 + - TOXENV=py34-dj19 +install: + - pip install tox +script: + - tox diff --git a/requirements/tests.txt b/requirements/tests.txt deleted file mode 100644 index 3bad74e..0000000 --- a/requirements/tests.txt +++ /dev/null @@ -1,3 +0,0 @@ -flake8 -coverage -django-discover-runner==1.0 diff --git a/setup.py b/setup.py index 1beef0e..dbda3bd 100644 --- a/setup.py +++ b/setup.py @@ -28,13 +28,8 @@ setup( author_email='jannis@leidel.info', license='BSD', url='http://django-appconf.readthedocs.org/', - packages=[ - 'appconf', - 'appconf.tests', - ], - install_requires=[ - 'six' - ], + packages=['appconf'], + install_requires=['six'], classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Web Environment', diff --git a/appconf/tests/__init__.py b/tests/__init__.py similarity index 100% rename from appconf/tests/__init__.py rename to tests/__init__.py diff --git a/appconf/tests/models.py b/tests/models.py similarity index 95% rename from appconf/tests/models.py rename to tests/models.py index a42ead3..11219f8 100644 --- a/appconf/tests/models.py +++ b/tests/models.py @@ -62,5 +62,5 @@ class CustomHolderConf(AppConf): class Meta: # instead of django.conf.settings - holder = 'appconf.tests.models.custom_holder' + holder = 'tests.models.custom_holder' prefix = 'custom_holder' diff --git a/appconf/tests/settings.py b/tests/settings.py similarity index 100% rename from appconf/tests/settings.py rename to tests/settings.py diff --git a/appconf/test_settings.py b/tests/test_settings.py similarity index 94% rename from appconf/test_settings.py rename to tests/test_settings.py index 4a41671..61f17d7 100644 --- a/appconf/test_settings.py +++ b/tests/test_settings.py @@ -14,7 +14,7 @@ INSTALLED_APPS = [ 'django.contrib.sites', 'django.contrib.auth', 'django.contrib.admin', - 'appconf.tests', + 'tests', ] if django.VERSION[:2] < (1, 6): diff --git a/appconf/tests/tests.py b/tests/tests.py similarity index 93% rename from appconf/tests/tests.py rename to tests/tests.py index 0a3dc85..6f9ed47 100644 --- a/appconf/tests/tests.py +++ b/tests/tests.py @@ -3,9 +3,9 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.test import TestCase -from appconf.tests.models import (AppConf, TestConf, PrefixConf, - YetAnotherPrefixConf, SeparateConf, - ProxyConf, CustomHolderConf, custom_holder) +from .models import (AppConf, TestConf, PrefixConf, + YetAnotherPrefixConf, SeparateConf, + ProxyConf, CustomHolderConf, custom_holder) class TestConfTests(TestCase): @@ -47,7 +47,7 @@ class TestConfTests(TestCase): self.assertEqual(custom_conf.CUSTOM_VALUE3, 'custom3') self.assertEqual(settings.TESTS_CUSTOM_VALUE3, 'custom3') self.assertEqual(custom_conf.TESTS_CUSTOM_VALUE3, 'custom3') - self.assertTrue('appconf.tests' in custom_conf.INSTALLED_APPS) + self.assertTrue('tests' in custom_conf.INSTALLED_APPS) def test_dir_members(self): custom_conf = TestConf() @@ -131,7 +131,7 @@ class RequiredSettingsTests(TestCase): def test_value_is_defined(self): class RequirementConf(AppConf): class Meta: - holder = 'appconf.tests.models.custom_holder' + holder = 'tests.models.custom_holder' prefix = 'holder' required = ['VALUE'] diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..aeb5e49 --- /dev/null +++ b/tox.ini @@ -0,0 +1,50 @@ +[tox] +skipsdist = True +usedevelop = True +minversion = 1.8 +envlist = + flake8-py27, + flake8-py33, + py{26,27}-dj14, + py{26,27,32,33}-dj{15,16}, + py{27,32,33,34}-dj{17,18,19}, + +[testenv] +basepython = + py26: python2.6 + py27: python2.7 + py32: python3.2 + py33: python3.3 + py34: python3.4 + pypy: pypy +usedevelop = true +setenv = + PYTHONPATH = {toxinidir} + DJANGO_SETTINGS_MODULE=tests.test_settings +deps = + flake8 + coverage + django-discover-runner + dj13: https://github.com/django/django/archive/stable/1.3.x.zip#egg=django + dj14: https://github.com/django/django/archive/stable/1.4.x.zip#egg=django + dj15: https://github.com/django/django/archive/stable/1.5.x.zip#egg=django + dj16: https://github.com/django/django/archive/stable/1.6.x.zip#egg=django + dj17: https://github.com/django/django/archive/stable/1.7.x.zip#egg=django + dj18: https://github.com/django/django/archive/stable/1.8.x.zip#egg=django + dj19: https://github.com/django/django/archive/master.zip#egg=django + +commands = + coverage run {envbindir}/django-admin.py test -v2 {posargs:tests} + coverage report + +[testenv:flake8-py27] +commands = flake8 appconf +deps = flake8 + +[testenv:flake8-py33] +commands = flake8 appconf +deps = flake8 + +[flake8] +exclude = .tox +ignore = E501