Pytest Example
This repo is a companion to the debugging and testing in python for LunarVim.
Setup Virtual Environment
Use whatever virtual environment manager you want, I'll be using conda.
conda create -n pytest python -y
conda activate pytest
conda install --file requirements.txt
Code Explanation
Here's a brief explanation of each file and directory:
- pytest_example/: The root directory for the project.
- calculator/: A directory containing the Calculator class.
-
init.py: An empty file that tells Python that the directory should be treated as a package.
- calculator.py: The file containing the Calculator class.
- tests/: A directory containing the unit tests for the Calculator class.
-
init.py: An empty file that tells Python that the directory should be treated as a package.
- test_calculator.py: The file containing the pytest unit tests for the Calculator class.
Run All Tests
You can run all tests from the cli with:
pytest tests/