Skip to content

Commit

Permalink
Changelog and README
Browse files Browse the repository at this point in the history
  • Loading branch information
mbi committed May 18, 2022
1 parent 4160620 commit f76550a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: [3.8, 3.9, "3.10"]

steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Version History

Version 0.5.18 (unreleased)
---------------------------
* Fix some typos in documentation (#210, thanks @stweil)
* Fix some typos in documentation (#210, thanks @stweil)
* Test against Django 4.1a
* Stopped testing Django < 3.2


Version 0.5.17
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Django Simple Captcha

.. image:: https://github.com/mbi/django-simple-captcha/actions/workflows/test.yml/badge.svg
:target: https://github.com/mbi/django-simple-captcha/actions/workflows/test.yml

.. image:: https://img.shields.io/pypi/v/django-simple-captcha
:target: https://pypi.org/project/django-simple-captcha/

Expand All @@ -28,7 +28,7 @@ Features
Requirements
++++++++++++

* Django 2.2+, Python3.6+
* Django 3.2+, Python3.8+
* A recent version of the Pillow compiled with FreeType support
* Flite is required for text-to-speech (audio) output, but not mandatory

Expand Down
17 changes: 4 additions & 13 deletions captcha/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import warnings

import django
from captcha.conf import settings
from captcha.fields import CaptchaField, CaptchaTextInput
from captcha.models import CaptchaStore
from django.core import management
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings
from django.utils import timezone
from PIL import Image
from testfixtures import LogCapture

from captcha.conf import settings
from captcha.fields import CaptchaField, CaptchaTextInput
from captcha.models import CaptchaStore

if django.VERSION < (1, 10): # NOQA
from django.core.urlresolvers import reverse # NOQA
else: # NOQA
Expand Down Expand Up @@ -423,16 +424,6 @@ def test_missing_value(self):
self.assertEqual(r.status_code, 200)
self.assertTrue(str(r.content).find("Form validated") > 0)

@unittest.skipUnless(django.VERSION < (1, 11), "Test only for Django < 1.11")
def test_autocomplete_off_django_110(self):
r = self.client.get(reverse("captcha-test"))
captcha_input = (
'<input type="text" name="captcha_1" autocomplete="off" spellcheck="false" autocorrect="off" '
'autocapitalize="off" id="id_captcha_1" />'
)
self.assertContains(r, captcha_input, html=True)

@unittest.skipIf(django.VERSION < (1, 11), "Test only for Django >= 1.11")
def test_autocomplete_off(self):
r = self.client.get(reverse("captcha-test"))
captcha_input = (
Expand Down
17 changes: 3 additions & 14 deletions captcha/tests/views.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
from captcha.fields import CaptchaField
from django import forms
from django.contrib.auth.models import User
from django.http import HttpResponse
from django.template import engines

try:
from django.template import engines

__is_18 = True
except ImportError:
from django.template import loader

__is_18 = False

from captcha.fields import CaptchaField

TEST_TEMPLATE = r"""
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Expand Down Expand Up @@ -39,10 +31,7 @@


def _get_template(template_string):
if __is_18:
return engines["django"].from_string(template_string)
else:
return loader.get_template_from_string(template_string)
return engines["django"].from_string(template_string)


def _test(request, form_class):
Expand Down
13 changes: 7 additions & 6 deletions captcha/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import subprocess
import tempfile

from captcha.conf import settings
from captcha.helpers import captcha_audio_url, captcha_image_url
from captcha.models import CaptchaStore
from django.core.exceptions import ImproperlyConfigured
from django.http import Http404, HttpResponse
from PIL import Image, ImageDraw, ImageFont
from ranged_response import RangedFileResponse

from captcha.conf import settings
from captcha.helpers import captcha_audio_url, captcha_image_url
from captcha.models import CaptchaStore

try:
from cStringIO import StringIO
except ImportError:
Expand Down Expand Up @@ -92,7 +93,7 @@ def captcha_image(request, key, scale=1):
charimage = charimage.rotate(
random.randrange(*settings.CAPTCHA_LETTER_ROTATION),
expand=0,
resample=Image.BICUBIC,
resample=Image.Resampling.BICUBIC,
)
charimage = charimage.crop(charimage.getbbox())
maskimage = Image.new("L", size)
Expand Down Expand Up @@ -204,8 +205,8 @@ def captcha_audio(request, key):


def captcha_refresh(request):
""" Return json with new captcha for ajax refresh request """
if not request.headers.get('x-requested-with') == 'XMLHttpRequest':
"""Return json with new captcha for ajax refresh request"""
if not request.headers.get("x-requested-with") == "XMLHttpRequest":
raise Http404

new_key = CaptchaStore.pick()
Expand Down
2 changes: 1 addition & 1 deletion testproject/jinja2_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .settings import * # noqa
from testproject.settings import * # noqa

FORM_RENDERER = "django.forms.renderers.Jinja2"
73 changes: 33 additions & 40 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@

[tox]
envlist =
py{37,38,39}-django{22,30},
py{37,38,39}-django{31,32},
py{38,39}-django40,
py310-django{32,40},
py{37,38,39}-django32-jinja2,
py{38,39,310}-django{32,40,41},
py{38,39,310}-django{32,40,41}-jinja2,
gettext,flake8,docs

[gh-actions]
python =
3.10: py310-django32, py310-django40, py310-django32-jinja2
3.9: py39-django22, py39-django30, py39-django31, py39-django32, py39-django40, py39-django32-jinja2
3.8: py38-django22, py38-django30, py38-django31, py38-django32, py38-django40, py38-django32-jinja2
3.7: py37-django22, py37-django30, py37-django31, py37-django32, py37-django32-jinja2, flake8
3.10: py310-django32, py310-django32-jinja2, py310-django40, py310-django40-jinja2, py310-django41, py310-django41-jinja2
3.9: py39-django32, py39-django32-jinja2, py39-django40, py39-django40-jinja2, py39-django41, py39-django41-jinja2
3.8: py38-django32, py38-django32-jinja2, py38-django40, py38-django40-jinja2, py38-django41, py38-django41-jinja2

[testenv]
changedir = testproject
Expand All @@ -24,46 +20,43 @@ setenv =
PYTHONDONTWRITEBYTECODE=1

deps =
django22: Django>=2.2a1,<2.3
django30: Django>=3.0a1,<3.1
django31: Django>=3.1a1,<3.2
django32: Django>=3.2a1,<3.3
django40: Django>=4.0a1,<4.1
django32: Django>=3.2,<3.3
django40: Django>=4.0,<4.1
django41: Django>=4.1a,<4.2
py{38,39,310}-django{32,40,41}: python3-memcached
jinja2

py{37,38,39,310}-django{22,30,31,32,40}: python3-memcached
extras =
test

[testenv:py37-django32-jinja2]
setenv =
DJANGO_SETTINGS_MODULE=jinja2_settings
deps =
jinja2
Django==3.2.*


[testenv:py38-django32-jinja2]
setenv =
DJANGO_SETTINGS_MODULE=jinja2_settings
deps =
jinja2
Django==3.2.*

commands = python -Wd manage.py test captcha --settings jinja2_settings

[testenv:py39-django32-jinja2]
setenv =
DJANGO_SETTINGS_MODULE=jinja2_settings
deps =
jinja2
Django==3.2.*

commands = python -Wd manage.py test captcha --settings jinja2_settings

[testenv:py310-django32-jinja2]
setenv =
DJANGO_SETTINGS_MODULE=jinja2_settings
deps =
jinja2
Django==3.2.*
commands = python -Wd manage.py test captcha --settings jinja2_settings


[testenv:py38-django40-jinja2]
commands = python -Wd manage.py test captcha --settings jinja2_settings

[testenv:py39-django40-jinja2]
commands = python -Wd manage.py test captcha --settings jinja2_settings

[testenv:py310-django40-jinja2]
commands = python -Wd manage.py test captcha --settings jinja2_settings

[testenv:py38-django41-jinja2]
commands = python -Wd manage.py test captcha --settings jinja2_settings

[testenv:py39-django41-jinja2]
commands = python -Wd manage.py test captcha --settings jinja2_settings

[testenv:py310-django41-jinja2]
commands = python -Wd manage.py test captcha --settings jinja2_settings



Expand Down Expand Up @@ -95,7 +88,7 @@ commands =
msgfmt -c -o zh_Hans/LC_MESSAGES/django.mo zh_Hans/LC_MESSAGES/django.po

[testenv:flake8]
basepython = python3.7
basepython = python3.8
deps = flake8==3.9.2
commands=
flake8 {toxinidir}/captcha
Expand Down

0 comments on commit f76550a

Please sign in to comment.