Skip to main content
EuroPythonCode of ConductBuy tickets

Code coverage through unit tests running in sub-processes/threads: Locally and automated on GitHub

Room:
Liffey A
Start:
09:45 on 13 July 2022
Duration:
45 minutes

Abstract

Unit testing and code coverage are two essential aspects of an open-source codebase. These unit tests often run in spawned sub-processes or threads as sub-processes or multi-threading allow them to run parallelly. They also make it easier to stop the tests midway if the process is taking too much time (probabilistic tests).

However, running unit tests in a sub-process creates a problem in the local repository as well as in the remote repository. As the documentation of coverage.py says — “Measuring coverage in those sub-processes can be tricky because you have to modify the code spawning the process to invoke coverage.py.”

TalkDevOps

Description

The “Code coverage” value of a codebase depicts how much of the production/development code is covered by the running unit tests. In the world of open-source, all the maintainers try their best to keep this percentage high, and this process is often automated through tools like GitHub Actions and Codecov. Hence, code coverage becomes a good metric (not always) to check if a particular codebase is well tested and reliable.

Open source maintainers often prefer to run these unit tests in sub-processes or threads as it allows them to run in parallel and reduce the CI (continuous integration) run time on pull requests. They also make it easier to stop the tests midway if they are taking too much time (probabilistic tests).

In this talk, we will first try to use coverage.py in the default mode on the unit tests running in a sub-process or a thread. After going through the results, we will build a solution to cover the “un-covered” code in the local repository. As a final step, we will also configure a CI (continuous integration) pipeline using GitHub Actions and Codecov to automate this process in our remote repository.


The speaker

Saransh Chopra

I am Saransh, a sophomore at the University of Delhi, pursuing a major in Information Technology and Mathematics. In daylight, I work towards my academic skills and professional commitments, and by night, I develop and maintain open-source research software written in Python, which I believe are the key to collaborative and reproducible research. Currently, I develop PyBaMM, BattBot, liionpack, and my contributions range from DeepXDE to Colour. I also like to experiment with Python a lot in the form of projects, which are all available on my GitHub!



← Back to schedule