Computational Modelling Group

Seminar  29th November 2017 6 p.m.  Nuffield Theatre Room 1081 (6/1081)

Python testing with pytest: motivation, demonstration, and practices

Mark Vousden

Web page
http://southampton-python.github.io/
Categories
Computational Social Science, Continuous Integration, Data Science, Digital Humanities, Docker, Git, IPython/Jupyter Notebook, Jenkins, Linux, Mercurial, NGCM, Pandas, Pylab, Python, Scientific Computing, Software Engineering
Submitter
Thomas Kluyver

Testing software ensures that simulation or application software remains functional throughout development, and proves that software operates a specific way when deployed or frozen. In software engineering, testing is a necessary practice for reliable software. This talk motivates the use of pytest to test Python code by outlining common requirements for a testing framework, and demonstrates the use of pytest.

One common requirement from a testing framework is that a developer must be able to test aspects of their software under many conditions without duplicating code, using test parameterisation. Another requirement is the need to test certain areas of code in isolation to more easily identify the cause of problems; this can be achieved by mocking areas that are tested elsewhere. Testing all code in every possible condition is ideal, but time must be budgeted to run the most essential tests. This limitation motivates the design of a fast-running test suite; this talk demonstrates running tests in parallel and across machines. After a summary, this talk concludes with a brief mention of other useful testing tools.