This is a repository full of examples of using pytest for the BI Vis Dev Team Lunch and Learn on 25th May 2022. Check out the confluence page for the Lunch and Learn here
Feel free to clone a copy of this repository to play around with it. Please ensure you create a branch of the code to work on and keep it up to date by occasionally pulling main into your branch.
Check out the pytest documentation here.
If you are unfamiliar with using Git and GitHub, here is a handy tutorial.
-
Clone the repository via https
git clone https://github.com/josephwilson8-nhs/TDD_lunch_and_learn.git
-
Create a personal branch to work off
git checkout -b <name_of_your_branch>
-
Pull in changes from main (Repeat when main is updated)
git pull origin main
-
Create a virtual environment
-
With pip venv
python3 -m venv <env_name> source <env_name>/bin/activate pip install -r requirements.txt echo <env_name> >> .gitignore
-
With conda
conda create --name <env_name> --file requirements.txt
-
-
To run all tests
pytest
-
To run all tests in a file
pytest test_file_name.py
-
To run all tests in a directory
pytest testing/
-
To run tests matching a custom marker
pytest -m marker_name
If using a custom marker, make sure to register the marker in the pytest.ini file.