Running unit tests with pytest
pytest is a Python testing framework that allows you to implement all kinds of tests, such as unit tests, integration tests, and end-to-end tests. pytest simplifies your work to develop these tests, as it requires less boilerplate code. If you’re already familiar with constructing functions and how to use the assert
keyword, this will come naturally to you.
A unit test is a crucial step in testing. It verifies the functionality and correctness of each component. It helps identify any errors in your code before the code is put into production.
In this recipe, we’ll cover how to run unit tests using pytest in Polars.
Getting ready
You need to have pytest installed. Execute the following command in your terminal to install the library:
pip install pytest
We need to create the project structure for this recipe. We’ll create a demo.py
file that contains all the transformation logic, and test_demo.py
under the test folder...