Tools¶
unittest2¶
- Just a backport of the
unittest
stuff in Python 2.7+ to Python 2.6 and previous.
doctest¶
- A way of testing Python code via docstrings and snippets in text files.
https://github.com/zopefoundation/ZODB/blob/master/src/ZODB/tests/testfsIndex.py#L197
nose¶
- An alternate test runner for unittest and nose-specific tests.
$ pip install nose
$ nosetests sample
py.test¶
- An alternate test runner for unittest and pytest-specific tests.
$ pip install pytest
$ py.test --pyargs sample
tox¶
- A way to test code under multiple versions of Python.
https://testrun.org/tox/latest/
Pyramid’s use of tox: https://github.com/Pylons/pyramid/blob/master/tox.ini
git bisect¶
- Track down the commit that caused an issue.
Condition/Decision coverage¶
Instrumental: https://pypi.python.org/pypi/instrumental
>>> def foo(a):
... return a == True or 2
...
>>> print foo(False)
2
>>> print foo(True)
True
Common Test Problems and Their Solutions¶
SQLAlchemy databases¶
http://www.sontek.net/blog/2011/12/01/writing_tests_for_pyramid_and_sqlalchemy.html
Mongo databases¶
Pyramid configuration¶
https://github.com/Pylons/substanced/blob/master/substanced/sdi/tests/test_sdi.py#L819