From 82040321023768a96612f1c3be393b45d0502699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksi=20H=C3=A4kli?= Date: Sat, 8 Dec 2018 15:38:00 +0200 Subject: [PATCH] Add Python 3.7 to supported versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Django 2.1 to the test matrix Fixes #371 Signed-off-by: Aleksi Häkli --- .prospector.yaml | 4 ++++ .travis.yml | 14 +++++++++----- axes/attempts.py | 14 +++++++------- axes/decorators.py | 4 ++-- axes/models.py | 6 +++--- axes/test_settings.py | 1 + requirements.txt | 8 ++++---- setup.py | 2 ++ tox.ini | 16 +++++++--------- 9 files changed, 39 insertions(+), 30 deletions(-) diff --git a/.prospector.yaml b/.prospector.yaml index 6414aca5..8fcf6051 100644 --- a/.prospector.yaml +++ b/.prospector.yaml @@ -10,5 +10,9 @@ pyflakes: disable: - F401 +pylint: + disable: + - old-style-class + dodgy: run: false diff --git a/.travis.yml b/.travis.yml index cc53c6af..6d9e432d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,15 @@ sudo: false language: python cache: pip -python: -- 2.7 -- 3.4 -- 3.5 -- 3.6 +matrix: + include: + - python: 2.7 + - python: 3.4 + - python: 3.5 + - python: 3.6 + - python: 3.7 + dist: xenial + sudo: true install: pip install tox-travis script: tox after_success: diff --git a/axes/attempts.py b/axes/attempts.py index 38a92428..d78b2245 100644 --- a/axes/attempts.py +++ b/axes/attempts.py @@ -210,12 +210,12 @@ def is_already_locked(request): failures_cached >= settings.AXES_FAILURE_LIMIT and settings.AXES_LOCK_OUT_AT_FAILURE ) - else: - for attempt in get_user_attempts(request): - if ( - attempt.failures_since_start >= settings.AXES_FAILURE_LIMIT and - settings.AXES_LOCK_OUT_AT_FAILURE - ): - return True + + for attempt in get_user_attempts(request): + if ( + attempt.failures_since_start >= settings.AXES_FAILURE_LIMIT and + settings.AXES_LOCK_OUT_AT_FAILURE + ): + return True return False diff --git a/axes/decorators.py b/axes/decorators.py index 712122f3..7a508572 100644 --- a/axes/decorators.py +++ b/axes/decorators.py @@ -69,12 +69,12 @@ def lockout_response(request): status=403, ) - elif settings.AXES_LOCKOUT_TEMPLATE: + if settings.AXES_LOCKOUT_TEMPLATE: return render( request, settings.AXES_LOCKOUT_TEMPLATE, context, status=403 ) - elif settings.AXES_LOCKOUT_URL: + if settings.AXES_LOCKOUT_URL: return HttpResponseRedirect(settings.AXES_LOCKOUT_URL) return HttpResponse(get_lockout_message(), status=403) diff --git a/axes/models.py b/axes/models.py index 4f0ce9f5..bc138440 100644 --- a/axes/models.py +++ b/axes/models.py @@ -46,7 +46,7 @@ class CommonAccess(models.Model): auto_now_add=True, ) - class Meta(object): + class Meta: app_label = 'axes' abstract = True ordering = ['-attempt_time'] @@ -72,7 +72,7 @@ def failures(self): def __str__(self): return 'Attempted Access: %s' % self.attempt_time - class Meta(object): + class Meta: verbose_name = _('access attempt') verbose_name_plural = _('access attempts') @@ -87,6 +87,6 @@ class AccessLog(CommonAccess): def __str__(self): return 'Access Log for %s @ %s' % (self.username, self.attempt_time) - class Meta(object): + class Meta: verbose_name = _('access log') verbose_name_plural = _('access logs') diff --git a/axes/test_settings.py b/axes/test_settings.py index 09c5727d..f552dd0b 100644 --- a/axes/test_settings.py +++ b/axes/test_settings.py @@ -19,6 +19,7 @@ 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', ) AUTHENTICATION_BACKENDS = ( diff --git a/requirements.txt b/requirements.txt index bb64ffc9..0ec6489d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -django -astroid==1.6.5 -prospector==0.12.11 -sphinx-rtd-theme -e . +coveralls==1.5.1 +mock==2.0.0 ; python_version <= "2.7" +prospector==1.1.6.2 +sphinx_rtd_theme==0.4.2 diff --git a/setup.py b/setup.py index 330ba961..56b8f209 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ package_dir={'axes': 'axes'}, install_requires=[ 'pytz', + 'django', 'django-appconf', 'django-ipware>=2.0.2', 'win_inet_pton ; python_version < "3.4" and sys_platform == "win32"', @@ -48,6 +49,7 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Internet :: Log Analysis', 'Topic :: Security', 'Topic :: System :: Logging', diff --git a/tox.ini b/tox.ini index c0704b0d..e20e1135 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,20 @@ [tox] envlist = - py{27,34,35,36}-django-111 - py{34,35,36}-django-20 - py{35,36}-django-master + py{27,34,35,36,37}-django-111 + py{34,35,36,37}-django-20 + py{35,36,37}-django-21 + py{35,36,37}-django-master [testenv] deps = - coveralls - django-appconf - django-ipware + -r requirements.txt django-111: django>=1.11,<2.0 django-20: django>=2.0,<2.1 + django-21: django>=2.1,<2.2 django-master: https://github.com/django/django/archive/master.tar.gz - astroid==1.6.5 - prospector==0.12.11 - py27: mock usedevelop = True ignore_outcome = + django-21: True django-master: True commands = coverage run -a --source=axes runtests.py -v2