Development

First, get a copy of the project:

cd ~/my_projects  # or whatever

git clone https://rolln.de/knoppo/django-model-permissions.git

cd django-model-permissions

Tip

You don’t need invoke or a virtualenv if you just want to run tox. It runs each environment in its own virtualenv. For anything else its highly recommended to create a virtualenv!

invoke

The easiest way to manage your development environment is to use invoke. Install it into your global site-packages by running pip install invoke as root. Then use inv -l in the git repository root to list available tasks.

virtualenv

Install virtualenv:

sudo pip install virtualenv
inv develop
virtualenv venv

. venv/bin/activate

python setup.py develop

virtualenvwrapper

Install virtualenvwrappper: http://virtualenvwrapper.readthedocs.io/en/latest/install.html#installation

inv develop -w
mkvirtualenv --python=/usr/bin/python3 django-model-permissions

setvirtualenvproject

python setup.py develop

Tests

inv test

The tox test matrix is updated regularly and runs the test-suite against sqlite, postgresql and current django versions on all installed python interpreters (except python2). See tox.ini or run tox -l in the repository for the current test matrix.

pip install tox

tox --skip-missing-interpreters

Note

You’ll want to create a virtualenv first! The tests have some dependencies which will clutter your global site-packages, otherwise.

cd tests/

python manage.py test -v 2

Running specific tests

  • Use the -e argument to run only one of the environments in the test matrix:

    tox -e py35-django21-sqlite
    
  • Use the --tag argument to run only tests decorated with a specific django.test.tag():

    First, decorate a class or a test function:

    from django.test import tag
    
    @tag('debug')
    class SomeTestCase(unittest.TestCase):
    
        @tag('debug')
        def test_xyz(self):
            pass
    
    inv test -a "--tag debug"
    
    tox -- --tag debug
    
    cd tests/
    
    python manage.py test --tag debug
    
  • Combine the two above to run one test in one tox environment:

    tox -e py35-django21-sqlite -- --tag debug
    

lint

inv lint
pip install -r tests/lint_requirements.txt

flake8 --statistics --count

Render the documentation

inv docs
cd docs/

pip install -r requirements.txt

sphinx-build -b html . _build/html

makemigrations

To create new migrations for the app run:

inv makemigrations

The test project is used to create migrations:

cd tests/

python manage.py migrate

python manage.py makemigrations model_permissions

python manage.py migrate