Python testing with pytest: motivation, demonstration, and practices
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.
6pm–7.30pm, 29th November 2017
Southampton University, Highfield Campus, Building 6 (Nuffield Theatre), Room 1081 (map)
Sustainable Scientific Software Development
In the experimental sciences, new theories are developed by applying the scientific method to produce results which are accurate, reproducible and reliable. This involves testing the experimental setup to show that it is working as designed and thoroughly documenting the progress of the experiment. Results will not be trusted unless the experiment has been carried out to a suitable standard.
In computational science, we should aim to apply the same principles. Results should only be trusted if the code that has produced it has undergone rigorous testing which demonstrates that it is working as intended, and any limitations of the code (e.g. numerical errors) are understood and quantified. The code should be well documented so that others can understand how it works and run it themselves to replicate results.
Unfortunately, this can be quite challenging. By their very nature, scientific codes are built to investigate systems where the behaviour is to some extent unknown, so testing them can be quite difficult. They can be very complex, built over a number of years (or even decades!) with contributions from many people. However, even for the most complicated of codes there are a number of different tools we can use to build robust, reliable code.
In this talk, I shall look at techniques and tools you can use to build more sustainable scientific code, including testing, continuous integration and documentation.
6pm–7.30pm, Thursday 5th October 2017
Southampton University, Highfield Campus, Building 7, Room 3023 (map)