Skip to content

Commit

Permalink
removed redundant code in middlware, added tox unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anx-ckreuzberger committed Sep 27, 2016
1 parent ad21f17 commit 7486112
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ django_userforeignkey.egg-info/**
.idea/**
venv/
build/
.tox/
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ Development and Tests
cd tests/user_foreign_key_testapp
python manage.py test
You can also use `tox` for testing, as it will test against Django 1.8, 1.9, 1.10 with Python versions 2.7, 3.4 and 3.5. See ``tox.ini`` for details.
15 changes: 2 additions & 13 deletions django_userforeignkey/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,9 @@
try:
from django.utils.deprecation import MiddlewareMixin
except:
# Django 1.8 and 1.9 compatibility
class MiddlewareMixin(object):
def __init__(self, get_response=None):
self.get_response = get_response
super(MiddlewareMixin, self).__init__()

def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
if not response:
response = self.get_response(request)
if hasattr(self, 'process_response'):
response = self.process_response(request, response)
return response
pass


logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
Expand Down
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tox]
envlist =
{py27,py33,py34,py35,pypy}-django18
{py27,py34,py35,pypy}-django19
{py27,py34,py35,pypy}-django10
skipsdist = True

[testenv]

deps =
django18: Django==1.8
django19: Django==1.9
django10: Django==1.10

commands =
python ../../setup.py install
python manage.py test

changedir = tests/user_foreign_key_testapp/

0 comments on commit 7486112

Please sign in to comment.