diff options
author | David Cramer <dcramer@gmail.com> | 2016-11-10 12:53:57 +0900 |
---|---|---|
committer | David Cramer <dcramer@gmail.com> | 2016-11-10 14:07:38 +0900 |
commit | f3878ac460114f3111a06416b00dc62baaae410e (patch) | |
tree | 5f0bc898338067de1e87b382f4c31a64ab451cf6 | |
parent | 8a04b60805ebcde45c596c917d50b5fc80e92b36 (diff) | |
download | raven-f3878ac460114f3111a06416b00dc62baaae410e.tar.gz |
Improve matrix builds; Drop Python 2.6ref/improve-travis
- Add Flask-specific builds
- Add Celery-specific builds
- Restore Django dev build
- Reduce Django builds to only focus on subset of versions
- Expand norecursedirs
- Drop Python 2.6 support (as deps are starting to)
- Update pytest-django
- Limit django-celery exposure
- Correct django-celery 3.1 behavior
-rw-r--r-- | .travis.yml | 88 | ||||
-rwxr-xr-x | ci/setup | 36 | ||||
-rwxr-xr-x | ci/test | 13 | ||||
-rw-r--r-- | conftest.py | 100 | ||||
-rw-r--r-- | raven/contrib/celery/__init__.py | 2 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rwxr-xr-x | setup.py | 6 | ||||
-rw-r--r-- | tests/versioning/tests.py | 16 |
8 files changed, 142 insertions, 121 deletions
diff --git a/.travis.yml b/.travis.yml index 1f1e630..ce726fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,68 +14,42 @@ cache: # secure: NMwOI1H9arp2vbgaidx9OY6y8990hiu0WsHtowEvEdGKXNzAQcy0sW3SoKcB6FN0bk11xhj49+5C++KAwMYwE/SL8Y5OoZ1/iYVI4/XlWNukr+1/pfPKVMgw3v5W+pL5Ba9TBdFfIoFPNYUDPLItSSjg94Bm95034gBkYWC5Hl0= # on: # tags: true -python: - - '2.6' - - '2.7' -# - '3.2' - - '3.3' - - '3.4' - - '3.5' - # pypy fails a lot, and generally should be compatible - # - pypy -env: - matrix: -# - DJANGO=Django==1.4.20 -# - DJANGO=Django==1.5.12 - - DJANGO=Django==1.6.11 -# - DJANGO=Django==1.7.11 - - DJANGO=Django==1.8.7 - - DJANGO=Django==1.9 - - DJANGO=Django==1.10 -# - DJANGO="-e git+git://github.com/django/django.git#egg=Django" install: - time ci/setup - pip install codecov "coverage<4" +before_script: + - pip freeze script: - if [[ ${TRAVIS_PYTHON_VERSION} != 'pypy' ]]; then make lint; fi - - coverage run --source=raven -m py.test tests --timeout 10 + - time ci/test after_success: - codecov -e DJANGO matrix: -# allow_failures: -# - env: DJANGO="-e git+git://github.com/django/django.git#egg=Django" - exclude: -# - python: '3.2' -# env: DJANGO=Django==1.4.20 -# - python: '3.2' -# env: DJANGO=Django==1.9 -# - python: '3.3' -# env: DJANGO=Django==1.4.20 - - python: '3.3' - env: DJANGO=Django==1.9 - - python: '3.3' - env: DJANGO=Django==1.10 -# - python: '3.4' -# env: DJANGO=Django==1.4.20 -# - python: '3.5' -# env: DJANGO=Django==1.4.20 -# - python: '3.5' -# env: DJANGO=Django==1.5.12 - - python: '3.5' - env: DJANGO=Django==1.6.11 -# - python: '3.5' -# env: DJANGO=Django==1.7.11 - - python: '3.5' - env: DJANGO=Django==1.8.7 - - python: '2.6' - env: DJANGO="-e git+git://github.com/django/django.git#egg=Django" - - python: '3.2' - env: DJANGO="-e git+git://github.com/django/django.git#egg=Django" - - python: '2.6' - env: DJANGO=Django==1.10 - - python: '2.6' - env: DJANGO=Django==1.9 - - python: '2.6' - env: DJANGO=Django==1.8.7 - - python: '2.6' - env: DJANGO=Django==1.7.11 + fast_finish: true + allow_failures: + - python: 3.5 + env: DJANGO=dev TEST_SUITE=django + include: + - python: 2.7 + env: FLASK=0.10.1 TEST_SUITE=flask + - python: 2.7 + env: FLASK=0.11.1 TEST_SUITE=flask + - python: 2.7 + env: DJANGO=1.6.11 TEST_SUITE=django + - python: 2.7 + env: DJANGO=1.8.7 TEST_SUITE=django + - python: 2.7 + env: DJANGO=1.9 TEST_SUITE=django + - python: 2.7 + env: DJANGO=1.10 TEST_SUITE=django + - python: 3.5 + env: DJANGO=1.10 TEST_SUITE=django + - python: 3.5 + env: DJANGO=dev TEST_SUITE=django + - python: 2.7 + env: CELERY=3.1 TEST_SUITE=celery + - python: 2.7 + env: CELERY=4.0 TEST_SUITE=celery + - python: 3.3 + - python: 3.4 + - python: 3.5 @@ -1,13 +1,35 @@ -#!/bin/bash -eu +#!/bin/bash -e -pip install $DJANGO +# we want wheel support when possible +pip install "pip>=8.1" + +if [ -n "$DJANGO" ]; then + if [[ "$DJANGO" == "dev" ]]; then + pip install -e git+git://github.com/django/django.git#egg=Django + else + pip install "Django==$DJANGO" + fi +fi +if [ -n "$FLASK" ]; then + pip install "Flask==$FLASK" +fi +if [ -n "$CELERY" ]; then + pip install "celery==$CELERY" +fi make bootstrap if [[ ${TRAVIS_PYTHON_VERSION::1} == '2' ]]; then pip install gevent fi -if [[ ${TRAVIS_PYTHON_VERSION} == '3.2' ]]; then - pip install -I https://github.com/celery/celery/archive/3.0.zip -fi -if [[ ${TRAVIS_PYTHON_VERSION::1} == '3' ]]; then - pip uninstall django-celery -y +# if [[ ${TRAVIS_PYTHON_VERSION} == '3.2' ]]; then +# pip install -I https://github.com/celery/celery/archive/3.0.zip +# fi + +DJANGO_BITS=(${DJANGO//./ }) +if [[ ${DJANGO_BITS[0]} -eq 1 && ${DJANGO_BITS[1]} -lt 8 ]]; then + # django-celery has fickle dependencies as its deprecated + pip install "django-celery>=3.1" "celery>=3.1,<4" + # newer versions of pytest-django dont support older versions of django + pip install "pytest-django<3.0" +elif [ -n "$DJANGO" ]; then + pip install "pytest-django>=3.0,<3.1" fi @@ -0,0 +1,13 @@ +#!/bin/bash -e + +if [[ $TEST_SUITE == 'django' ]]; then + TEST_PATH=tests/contrib/django +elif [[ $TEST_SUITE == 'flask' ]]; then + TEST_PATH=tests/contrib/flask +elif [[ $TEST_SUITE == 'celery' ]]; then + TEST_PATH=tests/contrib/test_celery.py +else + TEST_PATH=tests +fi + +coverage run --source=raven -m py.test $TEST_PATH --timeout 10 diff --git a/conftest.py b/conftest.py index 5c3b03f..e80bfb9 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,7 @@ -from django.conf import settings +from __future__ import absolute_import + import os.path +import pytest import sys @@ -20,6 +22,12 @@ try: except ImportError: collect_ignore.append("tests/contrib/webpy") +try: + import django # NOQA +except ImportError: + django = None + collect_ignore.append("tests/contrib/django") + INSTALLED_APPS = [ 'django.contrib.auth', @@ -40,46 +48,54 @@ except ImportError: use_djcelery = False -def pytest_configure(config): - where_am_i = os.path.dirname(os.path.abspath(__file__)) - - if not settings.configured: - settings.configure( - DATABASE_ENGINE='sqlite3', - DATABASES={ - 'default': { - 'NAME': ':memory:', - 'ENGINE': 'django.db.backends.sqlite3', - 'TEST_NAME': ':memory:', - }, +def configure_django(project_root): + from django.conf import settings + + settings.configure( + DATABASE_ENGINE='sqlite3', + DATABASES={ + 'default': { + 'NAME': ':memory:', + 'ENGINE': 'django.db.backends.sqlite3', + 'TEST_NAME': ':memory:', }, - DATABASE_NAME=':memory:', - TEST_DATABASE_NAME=':memory:', - INSTALLED_APPS=INSTALLED_APPS, - ROOT_URLCONF='tests.contrib.django.urls', - DEBUG=False, - SITE_ID=1, - BROKER_HOST="localhost", - BROKER_PORT=5672, - BROKER_USER="guest", - BROKER_PASSWORD="guest", - BROKER_VHOST="/", - SENTRY_ALLOW_ORIGIN='*', - CELERY_ALWAYS_EAGER=True, - TEMPLATE_DEBUG=True, - LANGUAGE_CODE='en', - LANGUAGES=(('en', 'English'),), - PROJECT_ROOT=where_am_i, - TEMPLATE_DIRS=[ - os.path.join(where_am_i, 'tests', 'contrib', 'django', 'templates'), + }, + DATABASE_NAME=':memory:', + TEST_DATABASE_NAME=':memory:', + INSTALLED_APPS=INSTALLED_APPS, + ROOT_URLCONF='tests.contrib.django.urls', + DEBUG=False, + SITE_ID=1, + BROKER_HOST="localhost", + BROKER_PORT=5672, + BROKER_USER="guest", + BROKER_PASSWORD="guest", + BROKER_VHOST="/", + SENTRY_ALLOW_ORIGIN='*', + CELERY_ALWAYS_EAGER=True, + TEMPLATE_DEBUG=True, + LANGUAGE_CODE='en', + LANGUAGES=(('en', 'English'),), + TEMPLATE_DIRS=[ + os.path.join(project_root, 'tests', 'contrib', 'django', 'templates'), + ], + TEMPLATES=[{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, + 'DIRS': [ + os.path.join(project_root, 'tests', 'contrib', 'django', 'templates'), ], - TEMPLATES=[{ - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'APP_DIRS': True, - 'DIRS': [ - os.path.join(where_am_i, 'tests', 'contrib', 'django', 'templates'), - ], - }], - ALLOWED_HOSTS=['*'], - DISABLE_SENTRY_INSTRUMENTATION=True, - ) + }], + ALLOWED_HOSTS=['*'], + DISABLE_SENTRY_INSTRUMENTATION=True, + ) + + +def pytest_configure(config): + if django: + configure_django(os.path.dirname(os.path.abspath(__file__))) + + +@pytest.fixture +def project_root(): + return os.path.dirname(os.path.abspath(__file__)) diff --git a/raven/contrib/celery/__init__.py b/raven/contrib/celery/__init__.py index cfc34cb..edf2c42 100644 --- a/raven/contrib/celery/__init__.py +++ b/raven/contrib/celery/__init__.py @@ -68,7 +68,7 @@ class SentryCeleryHandler(object): task_failure.disconnect(self.process_failure_signal) def process_failure_signal(self, sender, task_id, args, kwargs, einfo, **kw): - if self.ignore_expected and isinstance(einfo.exception, sender.throws): + if self.ignore_expected and hasattr(sender, 'throws') and isinstance(einfo.exception, sender.throws): return # This signal is fired inside the stack so let raven do its magic @@ -1,7 +1,7 @@ [tool:pytest] python_files=test*.py addopts=--tb=native -p no:doctest -norecursedirs=bin dist docs htmlcov hooks node_modules .* {args} +norecursedirs=raven build bin dist docs htmlcov hooks node_modules .* {args} [flake8] ignore = F999,E501,E128,E124,E402,W503,E731,F841 @@ -66,8 +66,6 @@ tests_require = [ 'six', 'bottle', 'celery>=2.5', - 'Django>=1.4', - 'django-celery>=2.5', 'exam>=0.5.2', 'flake8>=2.6,<2.7', 'logbook', @@ -75,8 +73,7 @@ tests_require = [ 'nose', 'pycodestyle', 'pytz', - 'pytest>=3.0.0', - 'pytest-django==2.9.1', + 'pytest>=3.0.0,<3.1.0', 'pytest-timeout==0.4', 'requests', 'tornado>=4.1', @@ -137,7 +134,6 @@ setup( 'Intended Audience :: System Administrators', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', diff --git a/tests/versioning/tests.py b/tests/versioning/tests.py index b3b49cb..bf3bcdd 100644 --- a/tests/versioning/tests.py +++ b/tests/versioning/tests.py @@ -5,13 +5,12 @@ import pytest import subprocess import six -from django.conf import settings - +from conftest import project_root from raven.versioning import fetch_git_sha, fetch_package_version -def has_git_requirements(): - return os.path.exists(os.path.join(settings.PROJECT_ROOT, '.git', 'refs', 'heads', 'master')) +def has_git_requirements(project_root): + return os.path.exists(os.path.join(project_root, '.git', 'refs', 'heads', 'master')) # Python 2.6 does not contain subprocess.check_output @@ -23,14 +22,15 @@ def check_output(cmd, **kwargs): ).communicate()[0] -@pytest.mark.skipif('not has_git_requirements()') -def test_fetch_git_sha(): - result = fetch_git_sha(settings.PROJECT_ROOT) +@pytest.mark.skipif(not has_git_requirements(project_root()), + reason='unable to detect git repository') +def test_fetch_git_sha(project_root): + result = fetch_git_sha(project_root) assert result is not None assert len(result) == 40 assert isinstance(result, six.string_types) assert result == check_output( - 'git rev-parse --verify HEAD', shell=True, cwd=settings.PROJECT_ROOT + 'git rev-parse --verify HEAD', shell=True, cwd=project_root ).decode('latin1').strip() |