Skip to content

Commit

Permalink
Update to Python 3.9 and only test Django 4.0 with 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
willbarton committed Jan 10, 2022
1 parent 4e1ad90 commit 43386e5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
25 changes: 11 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run tox -e lint
run: tox
env:
env:
TOXENV: lint

test:
Expand All @@ -34,23 +34,20 @@ jobs:
toxenv:
- py36-dj22
- py36-dj32
- py36-dj40
- py38-dj22
- py38-dj32
- py38-dj40
- py39-dj22
- py39-dj32
- py39-dj40
include:
- toxenv: py36-dj22
python-version: 3.6
- toxenv: py36-dj32
python-version: 3.6
- toxenv: py36-dj40
python-version: 3.6
- toxenv: py38-dj22
python-version: 3.8
- toxenv: py38-dj32
python-version: 3.8
- toxenv: py38-dj40
- toxenv: py39-dj22
python-version: 3.9
- toxenv: py39-dj32
python-version: 3.8
- toxenv: py39-dj40
python-version: 3.9
steps:
- uses: actions/checkout@v1

Expand All @@ -68,7 +65,7 @@ jobs:
run: |
tox
coveralls
env:
env:
TOXENV: ${{ matrix.toxenv }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion flags/state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.apps import apps
from django.core.exceptions import AppRegistryNotReady

from flags.models import FlagState
from flags.sources import get_flags


Expand All @@ -20,6 +19,8 @@ def _set_flag_state(
flag_name, state, create_boolean_condition=True, request=None
):
"""A private function to set a boolean condition to the desired state"""
from flags.models import FlagState

flags = get_flags(request=request)
flag = flags.get(flag_name)
if flag is None:
Expand Down
10 changes: 8 additions & 2 deletions flags/tests/test_conditions_validators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import django
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.test import TestCase, override_settings
Expand Down Expand Up @@ -87,8 +88,13 @@ class ValidateDateTestCase(TestCase):
def test_invalid_date_strings(self):
with self.assertRaises(ValidationError):
validate_date("tomorrowish")
with self.assertRaises(ValidationError):
validate_date("2020-04-01")

# Django 4.0 relies on Python 3.7+'s `datetime.fromisoformat()`, which
# handles this where the old regex did not. This is now valid when on
# Django 4.0+. See https://github.com/django/django/pull/14582
if django.VERSION < (4, 0):
with self.assertRaises(ValidationError):
validate_date("2020-04-01")

def test_valid_date_strings(self):
validate_date("2020-04-01T12:00")
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
[tox]
skipsdist=True
envlist=lint,py{36,38}-dj{22,32}
envlist=lint,py{36,39}-dj{22,32},py39-dj40

[testenv]
install_command=pip install -e ".[testing]" -U {opts} {packages}
commands=
coverage erase
coverage run --source='flags' {envbindir}/django-admin.py test {posargs}
coverage run --source='flags' {envbindir}/django-admin test {posargs}
coverage report -m
setenv=
DJANGO_SETTINGS_MODULE=flags.tests.settings

basepython=
py36: python3.6
py38: python3.8
py39: python3.9

deps=
dj22: Django>=2.2,<2.3
dj32: Django>=3.2,<3.3
dj40: Django==4
dj40: Django>=4.0,<4.1

[testenv:lint]
basepython=python3.8
basepython=python3.9
deps=
black
flake8
Expand Down

0 comments on commit 43386e5

Please sign in to comment.