https://en.wikipedia.org/wiki/Software_testing
https://en.wikipedia.org/wiki/Python_(programming_language)
Contents
https://en.wikipedia.org/wiki/Software_testing
- https://en.wikipedia.org/wiki/Test-driven_development
- https://en.wikipedia.org/wiki/Assertion_(computing)
- http://docs.python-guide.org/en/latest/writing/tests/
- http://martinfowler.com/bliki/TestCoverage.html
- http://martinfowler.com/eaaCatalog/
- https://en.wikipedia.org/wiki/Code_coverage#Basic_coverage_criteria
- https://en.wikipedia.org/wiki/Category:Formal_methods
- http://stackoverflow.com/questions/4904096/whats-the-difference-between-unit-functional-acceptance-and-integration-test
- http://stackoverflow.com/questions/520064/what-is-unit-test-integration-test-smoke-test-regression-test
1. edit, edit, commit 2. edit, commit 3. todo, edit, commit 4. todo, edit, test, commit 5. todo, test, edit, test, commit 6. todo, test, edit, test, commit, tag 7. todo, branch, test, edit, test, commit, { tag, push, send patch } 8. todo, qnew, test, edit, test, commit, finish, { tag, push, send patch }
- http://docs.python.org/2/library/unittest.html
- http://docs.python.org/2/library/doctest.html
- http://wiki.python.org/moin/PythonTestingToolsTaxonomy
- http://docs.python-guide.org/en/latest/writing/tests/
- https://pypi.python.org/pypi/unittest2 (python < 2.7)
- https://pypi.python.org/pypi/mock (python < 3.3)
- https://pypi.python.org/pypi/pathlib (python < 3.4)
- testtools
- https://docs.python.org/3/library/unittest.html
- https://docs.python.org/3/library/unittest.mock.html (python >= 3.3)
- https://docs.python.org/3/library/doctest.html
- https://docs.python.org/3/library/pathlib.html
- testtools
- https://mail.python.org/mailman/listinfo/python-porting
- http://python3porting.com/
- 2to3, six, nine, future
- https://hg.python.org/cpython/file/tip/Lib/lib2to3/Grammar.txt
- https://pythonhosted.org/setuptools/python3.html#supporting-both-python-2-and-python-3-with-setuptools
def test_true(): assert True == True %logstart log_input_to_here.py %logstart -o log_input_and_output_to_here.py %ed log_input_and_output_to_here.py !nosetests ./log_input_and_output_to_here.py !nosetests --help !nosetests --ipdb # pip install ipdbplugin # nose-progressive # Run a file in IPython's namespace, print timing, skip sys.exit %run -i -t -e ./log_input_and_output_to_here.py # Run a file in IPython's namespace, print timing, skip sys.exit, and pdb %run -i -t -e -d ./log_input_and_output_to_here.py # Add >>> and ... prompts (useful for recording doctests) %doctest_mode # List defined aliases %alias # Get help for an alias %logstart? %alias? # List available aliases and commands %<TAB> # Run a statement through the Python line profiler %prun test_true() %prun (2**2)*2) # Time a number of loops %timeit test_true() %timeit (lambda x: (x**2)*2)(10) # Run tests (see ipython_nose) %nose
- https://westurner.github.io/tools/#ipython-notebook
- https://westurner.github.io/tools/#jupyter-notebook
- https://pypi.python.org/pypi/runipy
- ipython_nose
- nosebook
.
- https://github.com/jiffyclub/ipythonblocks
- http://nbviewer.ipython.org/urls/raw.github.com/jiffyclub/ipythonblocks/master/demos/ipythonblocks_animation.ipynb
- https://en.wikipedia.org/wiki/Computer_data_logging
- https://en.wikipedia.org/wiki/Syslog
- http://docs.python.org/2/howto/logging.html
- http://docs.python.org/3/library/logging.config.html
A primer on Python logging (and testing):
#### Logging examples
# test setup (fixtures)
x = 2
data = {'x': x}
# asserts get compiled out with python -O2
assert x == 2
# these always run
class TestTwo(unittest.TestCase):
def test_001_x_equals_2(self):
self.assertEqual(self, x, 2)
unittest.main()
if x != 2:
### Exceptions
err = ('...', x)
raise Exception(err)
raise ValueError(err)
### Logging
import logging
log = logging # global logger
log = __import__('logging') # global logger
log = logging.getLogger(__name__) # local logger (<__name__>.py)
log.debug(err)
log.info(err)
log.error(err)
log.exception(err)
log.critical(err)
log.fatal(err)
# see: supervisor.loggers.LevelsByName and .LevelsByDescription
TRAC = LevelsByName.TRAC = 5
BLAT = LevelsByName.BLAT = 3
log.log(err, TRAC)
logging.addLevelName(TRAC, 'TRAC')
logging.addLevelName(BLAT, 'BLAT')
log.setLevel(TRAC)
log.log(err, BLAT) # not printed because msg.level < log.level
log.log((err, 'string'), BLAT)
# run unittest.main() when run like:
# python ./filename.py
# but not when imported like:
# import filename
if __name__ == "__main__":
import sys
sys.exit(unittest.main())
See also:
- structlog w/ logbook hynek/structlog#30 (comment)
Logbook is a drop-in replacement for the Python logging module with a number of simplifications and lots of additional handlers.
- MultiProcessingHandler https://logbook.readthedocs.io/en/stable/api/queues.html#logbook.queues.MultiProcessingHandler
- ThreadedWrapperHandler https://logbook.readthedocs.io/en/stable/api/queues.html#logbook.queues.ThreadedWrapperHandler
- structlog w/ logbook hynek/structlog#30 (comment)
- logging.handlers.SyslogHandler(logging.Handler) blocks
- https://docs.python.org/2/library/logging.handlers.html#sysloghandler
- http://www.somethinkodd.com/oddthinking/2010/04/29/how-python-logging-bit-me-part-1/
- logbook ThreadedWrapperHandler, MultiProcessingHandler
- "20.7 Interaction of rsyslog and journal" [journald] https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/s1-interaction_of_rsyslog_and_journal.htmlq
- Elasticsearch, MongoDB, Java 8+
GELF (Graylog Extended Log Format)
- ElasticSearch: storage, indexing, search
- Logstash: logging adapters
- Kibana: ElasticSearch Search UI
- Logstash GELF Plugin https://www.loggly.com/docs/rsyslog-tls-configuration/
https://en.wikipedia.org/wiki/Test-driven_development
https://en.wikipedia.org/wiki/Behavior-driven_development
- http://pythonhosted.org/lettuce/
- http://pythonhosted.org/lettuce/tutorial/simple.html
- http://heynemann.github.io/pyvows/
https://en.wikipedia.org/wiki/Mock_object
- http://mock.readthedocs.org/en/latest/index.html
- http://mock.readthedocs.org/en/latest/patch.html
- http://docs.python.org/3/library/unittest.mock.html
nosetests --help
nosetests --with-xunit
# python -m pdb --help
nosetests --pdb
nosetests --pdb-failures
nosetests --pdb-errors
# pip install nose_ipdb
nosetests --ipdb --ipdb-failure
# pip install nose-progressive
nosetests --with-progressive
nose-ipdb is a Nose plugin for running pdb debugger
with IPython (so tab completion, obj?
and obj??
all work.
nose-parameterized is a Nose plugin for separating test data from test code.
See also:
nose-progressive is a Nose plugin which adds a progress bar, better/different configurable tracebacks, and editor shortcuts
https://github.com/erikrose/nose-progressive#editor-shortcuts
export EDITOR='e'
ipython_nose is a Nose plugin for running test_*
functions
within the current Jupyter Notebook.
!pip install -e git+https://github.com/taavi/ipython_nose#egg=ipython_nose
%load_ext ipython_nose
def test_func():
assert sum([1, 1]) == 2
%nose # discover and run "test_*" functions
- nosebook is a Nose plugin for running test functions in Jupyter Notebooks from the CLI.
pip install pdbpp
nosetests --pdb
py.test --pdb # --full-trace
pip install pytest
py.test --pdb
- pytest-sugar adds a progressbar
- See also nose-progressive
- https://en.wikipedia.org/wiki/Continuous_integration
- https://en.wikipedia.org/wiki/Continuous_delivery
- https://en.wikipedia.org/wiki/Comparison_of_continuous_integration_software
- http://docs.python-guide.org/en/latest/scenarios/ci/
- https://github.com/saltstack/salt-jenkins
- https://wiki.jenkins-ci.org/display/JENKINS/ShiningPanda+Plugin
- xUnit XML
- https://nose.readthedocs.org/en/latest/plugins/xunit.html
- http://nosexunit.sourceforge.net/
- https://pytest.org/latest/usage.html#creating-junitxml-format-files
- https://github.com/xmlrunner/unittest-xml-reporting
- https://github.com/zandev/shunit2/compare/master...jeremycarroll:master
- http://about.travis-ci.org/docs/user/getting-started/
- https://github.com/audreyr/cookiecutter-pypackage/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/.travis.yml
- https://en.wikipedia.org/wiki/ACID
- https://en.wikipedia.org/wiki/Patch_(computing)
- https://en.wikipedia.org/wiki/Branching_(revision_control)
- https://en.wikipedia.org/wiki/Merge_(revision_control)
- https://en.wikipedia.org/wiki/Revision_control
- https://en.wikipedia.org/wiki/Distributed_revision_control
- http://savannah.nongnu.org/projects/quilt
- http://www.infoq.com/articles/agile-version-control
- http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
- http://linux.die.net/man/7/guilt
- http://hgbook.red-bean.com/read/advanced-uses-of-mercurial-queues.html
- http://mercurial.selenic.com/wiki/Bookmarks
- https://en.wikipedia.org/wiki/Code_Bisection
- https://www.kernel.org/pub/software/scm/git/docs/git-bisect.html
- https://www.kernel.org/pub/software/scm/git/docs/git-blame.html
- http://git-scm.com/book/en/Git-Tools-Debugging-with-Git
- http://www.selenic.com/mercurial/hg.1.html#bisect
- http://www.selenic.com/mercurial/hg.1.html#annotate
- http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html#sec:undo:bisect
- https://en.wikipedia.org/wiki/Debugging
- https://en.wikipedia.org/wiki/Breakpoint
- https://en.wikipedia.org/wiki/Program_animation
- https://en.wikipedia.org/wiki/Tracing_(software)
- https://en.wikipedia.org/wiki/Fault_injection
- https://en.wikipedia.org/wiki/Probe_effect
- https://scipy-lectures.github.io/advanced/debugging/
import pdb; pdb.set_trace() # pdb, pdbpp
import ipdb; ipdb.set_trace() # ipdb
nosetests --ipdb --ipdb-failure # --with-progressive # nose-progressive
pdb++ (pdbpp) is a "drop-in replacement for pdb" with additional debugging commands, tab completion, syntax highlighting, sticky mode,
- When pdb++ is installed (in
sys.path
) pdb++ overloads pdb:
pip install pdbpp funcsigs # installs pdb.py
python -m pdb ./code.py
nosetests --pdb ./code.py
py.test --pdb ./code.py
- https://dev.launchpad.net/UltimateVimPythonSetup (F7 for set_trace)
- http://winpdb.org/docs/
- https://github.com/lmacken/pyrasite-gui
- https://github.com/pybee/bugjar
- http://wiki.python.org/moin/IntegratedDevelopmentEnvironments#IDEs_with_introspection-based_code_completion_and_integrated_debugger
- http://www.jetbrains.com/pycharm/features/index.html#debugger
- http://www.activestate.com/komodo-ide/features#debugging
- http://pythonhosted.org/spyder/debugging.html
- http://pydev.org/manual_adv_debugger.html
- https://wingware.com/doc/debug
- https://pytools.codeplex.com/
- https://hg.python.org/cpython/file/tip/Tools/gdb/libpython.py
- https://hg.python.org/cpython/file/tip/Misc/README.valgrind
- https://hg.python.org/cpython/file/tip/Misc/valgrind-python.supp
- https://github.com/tmetsch/python-dtrace
- https://github.com/lmacken/pyrasite
- https://github.com/lmacken/pyrasite-gui
- https://github.com/google/pyringe
- https://github.com/alonho/pytrace
- https://github.com/haypo/pytracemalloc
- https://en.wikipedia.org/wiki/Instrumentation_(computer_programming)
- https://en.wikipedia.org/wiki/Profiling_(computer_programming)
- https://en.wikipedia.org/wiki/Call_graph
- https://docs.python.org/2/library/profile.html
- https://github.com/tobami/codespeed/
- https://github.com/numfocus/python-benchmarks
- https://github.com/scikit-learn/scikit-learn/tree/master/benchmarks
- https://github.com/pydata/vbench
- https://github.com/amcfague/linesman
- https://github.com/bdarnell/plop
- http://firelogger.binaryage.com#python
- https://github.com/scikit-learn/ml-benchmarks
- https://github.com/TechEmpower/FrameworkBenchmarks
- https://benchmarksgame.alioth.debian.org/
- http://rosettacode.org/wiki/Category:Programming_Tasks
- https://scipy-lectures.github.io/advanced/optimizing/
- http://pypy.org/performance.html
- http://scikit-learn.org/dev/developers/performance.html
- https://pandas-docs.github.io/pandas-docs-travis/enhancingperf.html
- http://ianozsvald.com/HighPerformancePythonfromTrainingatEuroPython2011_v0.2.pdf
- https://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-6B-HPC.ipynb
- https://en.wikipedia.org/wiki/Test_fixture
- https://factoryboy.readthedocs.org/en/latest/orms.html
- https://docs.djangoproject.com/en/dev/topics/testing/overview/#topics-testing-fixtures
- http://farmdev.com/projects/fixture/
- https://pypi.python.org/pypi/tablib
- https://pypi.python.org/pypi/anyconfig
- https://en.wikipedia.org/wiki/Schema_migration
- https://en.wikipedia.org/wiki/Database_refactoring
- https://en.wikipedia.org/wiki/Database_normalization
https://en.wikipedia.org/wiki/Web_application_framework
- https://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Python
- https://www.techempower.com/benchmarks/
Bottle is a one file WSGI Python web framework.
pgs is written with bottle.py:
WebTest is a tool for testing WSGI applications without running a webserver (e.g. Pyramid, Flask, Django, Bottle)
- multi webdrivers (chrome webdriver, firefox webdriver, phantomjs webdriver, zopetestbrowser, remote webdriver)
- css and xpath selectors *
Webkit based scriptable web browser for python.
- PyQT or PySide