Skip to content

Commit

Permalink
Fix tests for Django 2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
lefterisnik committed Dec 27, 2017
1 parent bca6581 commit c261ea2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ before_script:

# run tests
script:
- env
- flake8 .
- isort -c -df
- PYTHONPATH=`pwd` py.test --cov-report html --cov=admin_view_permission -v tests/
- |
if [ $DJANGO_VERSION != ^2$ && python != ^2.7$]; then
PYTHONPATH=`pwd` py.test --cov-report html --cov=admin_view_permission -v tests/
fi
# report coverage to coveralls.io
after_success: coveralls
34 changes: 24 additions & 10 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from admin_view_permission.enums import DjangoVersion
from admin_view_permission.utils import django_version

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


Expand Down Expand Up @@ -41,16 +44,27 @@
'tests.test_app'
]

MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
if django_version() < DjangoVersion.DJANGO_110:
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
else:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'tests.urls'

Expand Down

0 comments on commit c261ea2

Please sign in to comment.