Posts

Showing posts from March, 2023

PyTest Unit Testing Framework with Example.

Image
What is Pytest: Pytest Benefits: Pytest Installation: This tutorial uses Python 3 , and we will be working inside a virtualenv . Python 3 has inbuilt support for creating virtual environments. We can very easily create and use a virtual environment for this demo project.  We need to run the following commands in the cmd.  mkdir pytest_demo     # this will create directory. cd pytest_demo           # move to newly create directory Python3 -m venv pytest-demo   # this creates a virtual environment called pytest-env in our working directory. To see, Run command dir [on Mac or Unix OS] source pytest-demo/bin/activate .  # This activates virtual environment. As long as this virtualenv is active, any package we install will be installed in this new virtual environment.   [on Winodws OS] pytest-demo\Scripts\activate pip install pytest     # This installs pytest on virtual environment. pytest -h      ...