pytest-inline: An Inline Testing Tool for Python
We present pytest-inline, the first inline testing framework for Python. We recently proposed inline tests to make it easier to test individual program statements, but there is currently no framework-level support available for developers to write inline tests in Python. To fill this gap, we design and implement pytest-inline as a pytest plugin, which is the most popular Python testing framework. In pytest-inline, a developer can write inline tests by assigning test inputs to variables in the target statement and specifying the expected outputs. Then, pytest-inline runs each inline test and fails if the target statement’s output does not match the expected result. In this paper, we describe the design of pytest-inline, the testing features that it provides, and the intended use cases. Our evaluation of pytest- inline on the inline tests we wrote for 80 target statements from 31 open-source Python projects shows that using it to run inline tests incurs negligible overhead, at 0.012x. pytest-inline is open-sourced, and a video demo of pytest-inline can be found at https://www.youtube.com/watch?v=pZgiAxR_uJg.