diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1d33d0e..5d3ef6b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,4 +1,4 @@ -name: Python package +name: python package on: push: @@ -11,63 +11,162 @@ jobs: runs-on: ubuntu-latest strategy: matrix: -# python: [3.5, 3.6, 3.7, 3.8, 3.9] - python: [3.6, 3.7, 3.8, 3.9] django: [ - "Django>=1.11,<2.0", - "Django>=2.0,<2.1", - "Django>=2.1,<2.2", - "Django>=2.2,<3.0", - "Django>=3.0,<3.1", - "Django>=3.1,<3.2" + "django>=2.0,<2.1", + "django>=2.1,<2.2", + "django>=2.2,<3.0", + "django>=3.0,<3.1", + "django>=3.1,<3.2", + "django>=3.2,<4.0", + "django>=4.0,<4.1", + "django>=4.1,<4.2", + "django>=4.2,<5.0", ] -# exclude: -# - python: 3.5 -# django: Django>=3.0 + python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + exclude: + # django 2.0 + - django: "django>=2.0,<2.1" + python: "3.8" + - django: "django>=2.0,<2.1" + python: "3.9" + - django: "django>=2.0,<2.1" + python: "3.10" + - django: "django>=2.0,<2.1" + python: "3.11" + - django: "django>=2.0,<2.1" + python: "3.12" + # django 2.1 + - django: "django>=2.1,<2.2" + python: "3.4" + - django: "django>=2.1,<2.2" + python: "3.8" + - django: "django>=2.1,<2.2" + python: "3.9" + - django: "django>=2.1,<2.2" + python: "3.10" + - django: "django>=2.1,<2.2" + python: "3.11" + - django: "django>=2.1,<2.2" + python: "3.12" + # django 2.2 + - django: "django>=2.2,<3.0" + python: "3.4" + - django: "django>=2.2,<3.0" + python: "3.10" + - django: "django>=2.2,<3.0" + python: "3.11" + - django: "django>=2.2,<3.0" + python: "3.12" + # django 3.0 + - django: "django>=3.0,<3.1" + python: "3.4" + - django: "django>=3.0,<3.1" + python: "3.5" + - django: "django>=3.0,<3.1" + python: "3.10" + - django: "django>=3.0,<3.1" + python: "3.11" + - django: "django>=3.0,<3.1" + python: "3.12" + # django 3.1 + - django: "django>=3.1,<3.2" + python: "3.4" + - django: "django>=3.1,<3.2" + python: "3.5" + - django: "django>=3.1,<3.2" + python: "3.10" + - django: "django>=3.1,<3.2" + python: "3.11" + - django: "django>=3.1,<3.2" + python: "3.12" + # django 3.2 + - django: "django>=3.2,<4.0" + python: "3.4" + - django: "django>=3.2,<4.0" + python: "3.5" + - django: "django>=3.2,<4.0" + python: "3.11" + - django: "django>=3.2,<4.0" + python: "3.12" + # django 4.0 + - django: "django>=4.0,<4.1" + python: "3.4" + - django: "django>=4.0,<4.1" + python: "3.5" + - django: "django>=4.0,<4.1" + python: "3.6" + - django: "django>=4.0,<4.1" + python: "3.7" + - django: "django>=4.0,<4.1" + python: "3.11" + - django: "django>=4.0,<4.1" + python: "3.12" + # django 4.1 + - django: "django>=4.1,<4.2" + python: "3.4" + - django: "django>=4.1,<4.2" + python: "3.5" + - django: "django>=4.1,<4.2" + python: "3.6" + - django: "django>=4.1,<4.2" + python: "3.7" + - django: "django>=4.1,<4.2" + python: "3.12" + # django 4.2 + - django: "django>=4.2,<5.0" + python: "3.4" + - django: "django>=4.2,<5.0" + python: "3.5" + - django: "django>=4.2,<5.0" + python: "3.6" + - django: "django>=4.2,<5.0" + python: "3.7" steps: - uses: actions/checkout@v2 - - name: Setup Python + - name: setup python uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - - name: Install pytest, pytest-django and pytest-lazy-fixture, django and impostor + - name: install pytest, pytest-django and pytest-lazy-fixture, django and impostor run: | - pip install pytest==6.1.2 pytest-django==4.1.0 pytest-lazy-fixture==0.6.3 + pip install pytest==7.4.3 pytest-django==4.5.0 pytest-lazy-fixture==0.6.3 pip install "${{ matrix.django }}" pip install -e . - - name: Run tests - run: pytest -v + - name: run tests + run: pytest -v tests/ lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup Python + - name: setup python uses: actions/setup-python@v2 - - name: Install Tox and any other packages + - name: install tox and any other packages run: | pip install flake8 - - name: Lint with flake8 + - name: lint with flake8 run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + # stop the build if there are python syntax errors or undefined names + flake8 . --count --select=e9,f63,f7,f82 --show-source --statistics + # exit-zero treats all errors as warnings. the github editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics coverage: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup Python + - name: setup python uses: actions/setup-python@v2 - - name: Install Coverage + with: + python-version: "3.11" + - name: install coverage run: | - pip install django pytest pytest-django pytest-lazy-fixture pytest-cov + pip install django pytest==7.4.3 pytest-django==4.7.0 pytest-lazy-fixture==0.6.3 pytest-cov==4.1.0 pip install -e . - - name: Execute coverage + - name: execute coverage run: | # execute tests with coverage pytest --cov-report=xml --cov=impostor tests/ - export CODECOV_TOKEN="${{ secrets.CODECOV_TOKEN }}" + export codecov_token="${{ secrets.codecov_token }}" bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7955156..365728f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,24 +1,23 @@ repos: -- repo: https://github.com/ambv/black - rev: 20.8b1 +- repo: https://github.com/psf/black + rev: 22.10.0 hooks: - id: black exclude: .tox, venv -- repo: https://github.com/timothycrosley/isort - rev: 5.7.0 +- repo: https://github.com/PyCQA/isort + rev: 5.12.0 hooks: - id: isort files: .+\.py$ exclude: .tox, venv -- repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 +- repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 hooks: - id: flake8 files: .+\.py$ exclude: .tox, venv, migrations - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.3.0 + rev: v4.5.0 hooks: - id: debug-statements - files: .+\.py$ - exclude: .tox, venv \ No newline at end of file + files: .+\.py$ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 96a28cd..6132e80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 3.1.0 (2023-12-03) + * added support for django 4.1 and 4.2 + * added support for python 3.10, 3.11 and 3.12 + * dropped support for django 1.11 + * dropped support for pythjon 3.4, 3.5 and 3.6 + ## 3.0.0 (2022-04-15) * added support for django 3.2 and django 4.0 * implemented support for custom user model and custom USERNAME_FIELD ([Saurav Sharma](https://github.com/iamsauravsharma)) diff --git a/impostor/__init__.py b/impostor/__init__.py index c21777a..e70ba95 100644 --- a/impostor/__init__.py +++ b/impostor/__init__.py @@ -1,5 +1,5 @@ """Impostor.""" -__version__ = "3.0.0" +__version__ = "3.1.0" __author__ = "Marko Samastur" __email__ = "markos@gaivo.net" __mantainer__ = "Andreu Vallbona" diff --git a/impostor/templatetags/impostor_tags.py b/impostor/templatetags/impostor_tags.py index 2cc579f..e2e3f9c 100644 --- a/impostor/templatetags/impostor_tags.py +++ b/impostor/templatetags/impostor_tags.py @@ -1,6 +1,7 @@ """template tags for impostor.""" from django import template + from impostor.models import ImpostorLog register = template.Library() @@ -14,7 +15,9 @@ def get_impersonated_as(request): :return: """ try: - impersonated_as = ImpostorLog.objects.get(token=request.session['impostor_token']) + impersonated_as = ImpostorLog.objects.get( + token=request.session["impostor_token"] + ) except (ImpostorLog.DoesNotExist, KeyError): impersonated_as = None diff --git a/requirements-dev.txt b/requirements-dev.txt index 511ed94..fd5051b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,12 +1,16 @@ appdirs==1.4.4 -asgiref==3.2.10 +asgiref==3.7.2 attrs==19.3.0 +backcall==0.2.0 +coverage==7.3.2 decorator==4.4.2 -Django==3.1.7 +distlib==0.3.7 +Django==4.2.7 filelock==3.0.12 importlib-metadata==1.6.1 importlib-resources==1.5.0 -ipython==7.15.0 +iniconfig==2.0.0 +ipython==7.16.3 ipython-genutils==0.2.0 jedi==0.17.0 more-itertools==8.3.0 @@ -18,14 +22,15 @@ pluggy==0.13.1 prompt-toolkit==3.0.5 ptyprocess==0.6.0 py==1.10.0 -Pygments==2.7.4 +Pygments==2.17.2 pyparsing==2.4.7 -pytest==6.1.2 -pytest-django==4.1.0 +pytest==7.4.3 +pytest-cov==4.1.0 +pytest-django==4.7.0 pytest-lazy-fixture==0.6.3 pytz==2020.1 six==1.15.0 -sqlparse==0.3.1 +sqlparse==0.4.4 toml==0.10.1 tox==3.15.2 traitlets==4.3.3 diff --git a/setup.py b/setup.py index 7ebab53..7452a1a 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,6 @@ def read(fname): "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", - "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Framework :: Django :: 2.2", @@ -53,19 +52,22 @@ def read(fname): "Framework :: Django :: 3.1", "Framework :: Django :: 3.2", "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Framework :: Django :: 4.2", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Topic :: Utilities", ], install_requires=[ - "Django>=1.11", + "Django>=2.0", ], ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/settings.py b/tests/settings.py index 04f1dbd..cbda81a 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -11,7 +11,7 @@ "django.contrib.staticfiles", "django.contrib.auth", "impostor", - "tests.testapp.apps.TestAppConfig", + "tests.testapp", ] AUTHENTICATION_BACKENDS = ( diff --git a/tox.ini b/tox.ini index a0d341f..53b8900 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,16 @@ [tox] -envlist = py{35}-dj{111,20,21,22},py{36,37,38,39}-dj{111,20,21,22,30,31,32},py{36,37,38,39}-dj{111,20,21,22,30,31,32},py{38,39}-dj{40}, flake8 +envlist = + dj20-py{34,35,36,37} + dj21-py{35,36,37} + dj22-py{35,36,37,38,39} + dj30-py{36,37,38,39} + dj31-py{36,37,38,39} + dj32-py{36,37,38,39,310} + dj40-py{38,39,310} + dj41-py{38,39,310,311} + dj42-py{38,39,310,311,312} + flake8 + migrations skip_missing_interpreters=True [flake8] @@ -7,8 +18,7 @@ max-line-length = 120 [testenv] deps = - pytest==6.1.2 - pytest-django==4.1.0 + pytest-django==4.5.0 pytest-lazy-fixture==0.6.3 dj111: Django>=1.11,<2.0 dj20: Django>=2.0,<2.1 @@ -18,6 +28,10 @@ deps = dj31: Django>=3.1,<3.2 dj32: Django>=3.2,<4.0 dj40: Django>=4.0,<4.1 + dj41: Django>=4.1,<4.2 + dj42: Django>=4.2,<5 + py34,py35,py36,py37,py38: pytest==6.1.2 + py39,py310,py311,py312: pytest==7.4.3 setenv = PYTHONPATH = {toxinidir}:{toxinidir} @@ -26,11 +40,11 @@ commands = pytest {posargs:tests} [testenv:migrations] -basepython = python3.9 +basepython = python3.11 commands = python tests/manage.py makemigrations testapp [testenv:flake8] -basepython = python3.8 +basepython = python3.11 deps = flake8==3.9.0 commands =