Developer Resources

Style Guide

Follow the Python Syle Guide.

Running from source

While developing, it is convienent to run the changed code without uninstalling/installing. Nodeworks can be start in the top level source directory by:

python -m nodeworks

Or, nodeworks can be installed in develop mode:

python setup.py develop

Documentation

This documentation is created using sphinx. The source files for the documentation can be found in the docs/source directory.

To build the html documentation, run the following command:

$ python setup.py build_sphinx

The documentation can also be built by going to the docs directory and use the following command:

$ make html

Basic reStructuredText syntax can be referenced here.

Testing

The test harness is run using pytest. To install pytest with pip:

$ pip install pytest

Tests should located in directories named tests along side the modules they are testing. The name of the test files starts with ‘test_’ followed by the module that is being tested.

To run the test harness, run pytest from the command line:

$ pytest

To run a specific test file, use this command:

$ pytest tests/test_foobar.py

To run a specific test by name:

$ pytest -k TestCase

pytest can also measure the code coverage of the tests by using the coverage plugin. To get the coverage plugin, install it useing pip:

$ pytest install pytest-cov

To get a report on the command line, use these flags when running pytest:

$ pytest --color=yes --no-cov-on-fail --cov=tests --cov-report=term-missing:skip-covered tests

To generate a nice html report showing all the lines that are covered, use the following flags:

$ pytest --color=yes --no-cov-on-fail --cov=tests --cov-report=html tests

html files will be created in nodeworksdocstestcoverage, with index.html being the entry point.

Qt provides testing tools to mimic user interaction.

from qtpy import QtGui, QtCore, QtTest

# click <widget> with left mouse button
QtTest.QTest.mouseClick(<widget>, QtCore.Qt.LeftButton)

Building conda package

First install/update conda build:

# conda install conda-build

The conda package can be constructed by running the following command in the top level of the repository:

$ conda build conda_recipe

The package can then be tested by installing with:

$ conda install --offline path\to\conda-bld\noarch\nodeworks*.tar.bz2

Building whl file

Since Nodeworks is pure python, a universal wheel file can be built with the following command:

$ python setup.py bdist_wheel --universal

This wheel file can be installed in both python 2 and python 3 installations by running:

$ pip install nodeworks.whl