Skip to content

Commit

Permalink
Try fix tox test py27, 37
Browse files Browse the repository at this point in the history
  • Loading branch information
obieler committed Sep 17, 2024
1 parent 049d239 commit 9a336f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
Expand All @@ -14,7 +14,17 @@ jobs:
steps:
- uses: actions/checkout@v2

# Special handling for Python 2.7
- name: Set up Python 2.7 and pip (+ install dependencies)
if: matrix.python-version == '2.7'
run: |
sudo apt-get update
sudo apt-get install -y python2.7 python-pip
python2.7 -m pip install --upgrade "pip<21.0" "setuptools<45"
python2.7 -m pip install tox==3.24.4 tox-gh-actions
- name: Set up Python ${{ matrix.python-version }}
if: matrix.python-version != '2.7'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -33,7 +43,8 @@ jobs:
restore-keys: |
${{ matrix.python-version }}-v1-
- name: Install dependencies
- name: Install dependencies for Python 3.x
if: matrix.python-version != '2.7'
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade tox tox-gh-actions
Expand Down
12 changes: 7 additions & 5 deletions authority/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
from django.core.exceptions import PermissionDenied

from sys import version_info as python_version
if django_version[0] >= 4:
if django_version >= (4, 0):
from django.utils.encoding import force_str as force_text # Django 4.x
elif django_version[0] >= 2:
elif django_version >= (2, 0):
from django.utils.encoding import force_text # Django 2.x and 3.x
else:
elif django_version >= (1, 11):
if python_version[0] < 3:
from django.utils.encoding import force_unicode as force_text # Django 1.x with Python 2.x
from django.utils.encoding import force_unicode as force_text # Django 1.x with Python 2.7
else:
raise ImportError("Unsupported Django version or Python version")
from django.utils.encoding import force_text
else:
raise ImportError("Unsupported Django version or Python version")

from authority.models import Permission
from authority.widgets import GenericForeignKeyRawIdWidget
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ commands =
coverage xml
deps =
coverage
setuptools
dj111: Django>=1.11,<2.0
dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
Expand Down

0 comments on commit 9a336f5

Please sign in to comment.