Skip to content

Commit

Permalink
updated CI to latest django
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Jan 7, 2021
1 parent 654c2ba commit 3e8439c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 57 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ python: 3.6
dist: xenial

env:
- TOX_ENV=pypy-django11
- TOX_ENV=py27-django11
- TOX_ENV=py35-django11
# generate with: tox -l
- TOX_ENV=py35-django22
- TOX_ENV=py36-django11
- TOX_ENV=py36-django22
- TOX_ENV=py37-django11
- TOX_ENV=py37-django22
- TOX_ENV=py37-django30
- TOX_ENV=py38-django11
- TOX_ENV=py37-django31
- TOX_ENV=py38-django22
- TOX_ENV=py38-django30
- TOX_ENV=py39-django11
- TOX_ENV=py38-django31
- TOX_ENV=py39-django22
- TOX_ENV=py39-django30
- TOX_ENV=py39-django31
- TOX_ENV=py310-django22
- TOX_ENV=py310-django30
- TOX_ENV=py310-django31
- TOX_ENV=flake8
- TOX_ENV=docs
- TOX_ENV=coveralls
Expand Down
48 changes: 23 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,39 @@ Usage

To enable easy to use choices which are more convenient than the Django 3.0 choices system you can use this:

```python
.. code-block:: python
from django_utils import choices
from django_utils import choices
# For manually specifying the value (automatically detects `str`, `int` and `float`):
class Human(models.Model):
class Gender(choices.Choices):
MALE = 'm'
FEMALE = 'f'
OTHER = 'o'
# For manually specifying the value (automatically detects `str`, `int` and `float`):
class Human(models.Model):
class Gender(choices.Choices):
MALE = 'm'
FEMALE = 'f'
OTHER = 'o'
gender = models.CharField(max_length=1, choices=Gender)
gender = models.CharField(max_length=1, choices=Gender)
# To define the values as `male` implicitly:
class Human(models.Model):
class Gender(choices.Choices):
MALE = choices.Choice()
FEMALE = choices.Choice()
OTHER = choices.Choice()
# To define the values as `male` implicitly:
class Human(models.Model):
class Gender(choices.Choices):
MALE = choices.Choice()
FEMALE = choices.Choice()
OTHER = choices.Choice()
gender = models.CharField(max_length=1, choices=Gender)
gender = models.CharField(max_length=1, choices=Gender)
# Or explicitly define them
class Human(models.Model):
class Gender(choices.Choices):
MALE = choices.Choice('m', 'male')
FEMALE = choices.Choice('f', 'female')
OTHER = choices.Choice('o', 'other')
# Or explicitly define them
class Human(models.Model):
class Gender(choices.Choices):
MALE = choices.Choice('m', 'male')
FEMALE = choices.Choice('f', 'female')
OTHER = choices.Choice('o', 'other')
gender = models.CharField(max_length=1, choices=Gender)
```
gender = models.CharField(max_length=1, choices=Gender)
A PostgreSQL ENUM field will be coming soon to automatically facilitate the creation of the enum if needed.

Expand Down
6 changes: 3 additions & 3 deletions django_utils/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def __new__(cls, name, bases, attrs):
choices = list()
has_values = False

# Chicken-Egg problem, can't check for something that doesn't exist yet
# Chicken-Egg problem, can't check for something that doesn't exist
# yet. That's why we check for the name of the class instead of a
# `issubclass`
literal = False
for base in bases:
if base.__name__ == 'LiteralChoices':
Expand Down Expand Up @@ -320,8 +322,6 @@ class LiteralChoices(Choices):
['admin', 'user', 'guest']
>>> Role.choices.keys()
['admin', 'user', 'guest']
>>> Role.ADMIN
<Choice[1]:admin>
>>> Role.admin
'admin'
'''
10 changes: 3 additions & 7 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ addopts =
--cov-report html
--no-cov-on-fail
--doctest-modules
--pep8
--flakes
--flake8

pep8ignore =
*.py W391
docs/*.py ALL

flakes-ignore =
flake8-ignore =
*.py W391 W504
docs/*.py ALL

DJANGO_SETTINGS_MODULE=tests.settings
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def run_tests(self):
'pytest-cache',
'pytest-cov',
'pytest-django',
'pytest-flakes',
'pytest-pep8',
'pytest-flake8',
'jinja2',
'pygments',
],
Expand Down
18 changes: 5 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
[tox]
envlist =
py{py,27}-django11,
py35-django{11,22},
py36-django{11,22},
py37-django{11,22,30},
py38-django{11,22,30},
py39-django{11,22,30},
py3{5,6}-django{22},
py3{7,8,9,10}-django{22,30,31},
flake8,
docs

Expand All @@ -14,18 +10,14 @@ usedevelop = True

[testenv]
deps =
django11: Django<2.0
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
-r{toxinidir}/tests/requirements.txt

envlist =
py{py,27}-django11,
py35-django{11,22,30},
py36-django{11,22,30},
py37-django{11,22,30},
py38-django{11,22,30},
py39-django{11,22,30},
py3{5,6}-django{22},
py3{7,8,9,10}-django{22,30,31}

commands =
python setup.py test
Expand Down

0 comments on commit 3e8439c

Please sign in to comment.