Install Morepath for development¶
First make sure you have virtualenv installed for Python 2.7.
Now create a new virtualenv somewhere for Morepath development:
$ virtualenv /path/to/ve_morepath
You should also be able to recycle an existing virtualenv, but this guarantees a clean one. Note that we skip activating the environment here, as this is just needed to initially bootstrap the Morepath buildout.
Clone Morepath from github and go to the morepath directory:
$ git clone firstname.lastname@example.org:morepath/morepath.git $ cd morepath
Now we need to run bootstrap.py to set up buildout, using the Python from the virtualenv we’ve created before:
$ python /path/to/ve_morepath/bin/python/bootstrap.py
This installs buildout, which can now set up the rest of the development environment:
This downloads and installs various dependencies and tools. The
commands you run in
bin are all restricted to the virtualenv you
set up before. There is therefore no need to refer to the virtualenv
once you have the development environment going.
Running the tests¶
You can run the tests using py.test. Buildout has installed it for
you in the
bin subdirectory of your project:
$ bin/py.test morepath
To generate test coverage information as HTML do:
$ bin/py.test morepath --cov morepath --cov-report html
You can then point your web browser to the
in the project directory and click on modules to see detailed coverage
The buildout also installs flake8, which is a tool that can do various checks for common Python mistakes using pyflakes and checks for PEP8 style compliance.
To do pyflakes and pep8 checking do:
$ bin/flake8 morepath
The buildout installs radon. This is a tool that can check various measures of code complexity.
To check for cyclomatic complexity (excluding the tests):
$ bin/radon cc morepath -e "morepath/tests*"
To filter for anything not ranked
$ bin/radon cc morepath --min B -e "morepath/tests*"
And to see the maintainability index:
$ bin/radon mi morepath -e "morepath/tests*"