Skip to content

Commit

Permalink
Modernize test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby authored and dfunckt committed Jul 22, 2018
1 parent e00153e commit c7c1d32
Show file tree
Hide file tree
Showing 24 changed files with 610 additions and 897 deletions.
8 changes: 0 additions & 8 deletions .coveragerc

This file was deleted.

51 changes: 12 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
# ---------------------------------------------------------------------------
# Python support matrix per Django version
#
# 2.6 1.5 1.6
# 2.7 1.5 1.6 1.7 1.8 1.9 1.10 1.11
# 3.3 1.5 1.6 1.7 1.8
# 3.4 1.7 1.8 1.9 1.10 1.11 2.0
# 3.5 1.8 1.9 1.10 1.11 2.0
# 3.6 1.10 1.11 2.0
# ---------------------------------------------------------------------------
sudo: false
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "pypy"
- "pypy3"

matrix:
include:
- { python: 2.6, env: TOXENV=py26-django15 }
- { python: 2.6, env: TOXENV=py26-django16 }
- { python: 2.7, env: TOXENV=py27-django15 }
- { python: 2.7, env: TOXENV=py27-django16 }
- { python: 2.7, env: TOXENV=py27-django17 }
- { python: 2.7, env: TOXENV=py27-django18 }
- { python: 2.7, env: TOXENV=py27-django19 }
- { python: 2.7, env: TOXENV=py27-django110 }
- { python: 2.7, env: TOXENV=py27-django111 }
- { python: 3.3, env: TOXENV=py33-django15 }
- { python: 3.3, env: TOXENV=py33-django16 }
- { python: 3.3, env: TOXENV=py33-django17 }
- { python: 3.3, env: TOXENV=py33-django18 }
- { python: 3.4, env: TOXENV=py34-django17 }
- { python: 3.4, env: TOXENV=py34-django18 }
- { python: 3.4, env: TOXENV=py34-django19 }
- { python: 3.4, env: TOXENV=py34-django110 }
- { python: 3.4, env: TOXENV=py34-django20 }
- { python: 3.4, env: TOXENV=py34-django111 }
- { python: 3.5, env: TOXENV=py35-django18 }
- { python: 3.5, env: TOXENV=py35-django19 }
- { python: 3.5, env: TOXENV=py35-django110 }
- { python: 3.5, env: TOXENV=py35-django111 }
- { python: 3.5, env: TOXENV=py35-django20 }
- { python: 3.6, env: TOXENV=py36-django110 }
- { python: 3.6, env: TOXENV=py36-django111 }
- { python: 3.6, env: TOXENV=py36-django20 }
- {python: "3.6", env: TOXENV=packaging}

install:
- if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then pip install virtualenv==15.2.0; fi
- pip install tox
- pip install tox tox-travis tox-venv
- pip install coveralls
script: tox
after_success:
- coveralls
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ Table of Contents
Requirements
============

``rules`` requires Python 2.6/3.3 or newer. It can optionally integrate with
Django, in which case requires Django 1.5 or newer.
``rules`` requires Python 2.7/3.4 or newer. It can optionally integrate with
Django, in which case requires Django 1.11 or newer.


How to install
Expand Down
150 changes: 0 additions & 150 deletions rules/compat/access_mixins.py

This file was deleted.

8 changes: 1 addition & 7 deletions rules/contrib/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
from django.contrib import admin

try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
from django.contrib.auth import get_permission_codename


class ObjectPermissionsModelAdminMixin(object):
Expand Down
9 changes: 2 additions & 7 deletions rules/contrib/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth import mixins
from django.contrib.auth.views import redirect_to_login
from django.core.exceptions import PermissionDenied, ImproperlyConfigured, FieldError
from django.shortcuts import get_object_or_404
from django.utils import six
from django.utils.decorators import available_attrs
from django.utils.encoding import force_text

try:
from django.contrib.auth import mixins
except ImportError: # pragma: no cover
# Django < 1.9
from ..compat import access_mixins as mixins


# These are made available for convenience, as well as for use in Django
# versions before 1.9. For usage help see Django's docs for 1.9 or later.
Expand Down Expand Up @@ -124,7 +119,7 @@ def _wrapped_view(request, *args, **kwargs):
# Get the object to check permissions against
if callable(fn):
obj = fn(request, *args, **kwargs)
else:
else: # pragma: no cover
obj = fn

# Get the user
Expand Down
9 changes: 2 additions & 7 deletions rules/templatetags/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@


register = template.Library()
try:
# Django < 2.0
simple_tag = register.assignment_tag
except AttributeError: # pragma: no cover
simple_tag = register.simple_tag


@simple_tag
@register.simple_tag
def test_rule(name, obj=None, target=None):
return default_rules.test_rule(name, obj, target)


@simple_tag
@register.simple_tag
def has_perm(perm, user, obj=None):
if not hasattr(user, 'has_perm'): # pragma: no cover
return False # swapped user model that doesn't support permissions
Expand Down
47 changes: 0 additions & 47 deletions runtests.py

This file was deleted.

11 changes: 5 additions & 6 deletions runtests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/sh
coverage run --source=rules runtests.py --nologcapture --nocapture "$@"
result=$?
echo
coverage report -m
echo
exit $result

# NOTE: Make sure you `pip install -e .` first
coverage run tests/manage.py test --failfast -v2 testsuite "$@" \
&& echo \
&& coverage report -m
17 changes: 12 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[nosetests]
verbosity=2
cover-package=rules
cover-erase=1
#cover-branches=1
[bdist_wheel]
universal = 1

[coverage:run]
source = rules

[coverage:report]
exclude_lines =
pragma: no cover
omit =
*/rules/apps.py
*/rules/compat/*
Loading

0 comments on commit c7c1d32

Please sign in to comment.