networkx/networkx — pull request #752 by jtorrents (2012-08-10 16:13:08+00:00)
Title: Adapt ipython tools for testing pull requests

@ipython has a very nice set of tools for their github based development workflow. See:

https://github.com/ipython/ipython/tree/master/tools

As @fperez suggested at SciPy 2012, it is easy and useful to adapt some of them for NetworkX development. This pull request adapts the test_pr.py script and friends for NetworkX. It automatically tests pull requests (using virtualenv and downloading the code directly from github) and optionally posts the results as a comment in the pull request page (including a link to a gist with the log for failed tests). It is a very nice and useful tool. For the origunal ipython pr_test.py see:

https://github.com/ipython/ipython/blob/master/tools/test_pr.py

I did some changes on how the tests are run inside each virualenv. IPython uses a script for running tests which is installed at the 'bin' directory of each virtialenv. But I think it is easier for NetworkX tests to simply use check_output:

```python
py = os.path.join(basedir, venv, 'bin', 'python')
cmd = [py, '-c', 'import networkx as nx; nx.test(verbosity=2,doctest=True)']
log = check_output(cmd, stderr=STDOUT).decode('utf-8')
```

I also added PyPy support (last commit). But I'm not sure if it will work in something different than a Debian based system. PyPy and virtualenv play nice together and no significative change in the code is required, but in Debian/Ubuntu systems the option `--system-site-packages` of virtialenv does not add the actual dist-packages path for pypy (`/usr/local/lib/pypy2.7/dist-packages`). As a quick and dirty solution, I've opted for adding the path explicitly in `run_tests()` to be able to import nose, but it is not a solid solution. So more work is needed. I'll be quite busy the next days and I'm not sure if I will be able to work on this, so I'm posting it hoping than someone can take a look, test it in other systems and also work on it.

This script assumes that there is a directory named `.nx_pr_tests` in your home directory and that the nose package and other libraries are installed system wide in each python environment. It does not import anything from the user defined `$PYTHONPATH`.