A brand new project.
- How to clone a GitHub repo: https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
- How to clone a git repo: https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
Get it from https://www.python.org/downloads/
- Open a command/terminal and navigate to the cloned repo location.
- Create a venv [OPTIONAL]
python -m venv .venv
- Windows:
"C:\Program Files\Python311\python.exe" -m venv .venv311
if you want to target a specific python version.
- Enable your venv [OPTIONAL]
- Windows/PowerShell:
.venv\Scripts\Activate.ps1
- Windows/PowerShell:
.venv311\Scripts\Activate.ps1
if you want to target your specific python version. - When you're not sure to have your venv enabled, you can check if your default python executable is located in your virtual environment.
Check where is located your default python executablepython -c "import sys; print(sys.executable)"
If your venv is enable, it should return something like:.venv\Scripts\python.exe
- Windows/PowerShell:
- Upgrade
pip
python -m pip install --upgrade pip
- Install the dependencies with pip:
pip install -r requirements.txt
- Run it!
python.exe -m examples.main main
- All the tests:
python -m unittest discover -v -s "tests" -p "*_test.py" -t "."
- A test file:
python -m unittest -v 'tests.unit.fibonacci_test'
- A test class:
python -m unittest -v 'tests.unit.fibonacci_test.Fibo_Test'
- A single test:
python -m unittest -v 'tests.unit.fibonacci_test.Fibo_Test.test_callWithValidInput_0'
coverage
is part the installed packages, you just need to:
- Run the unit tests with
coverage
:- All the unit tests:
coverage run -m unittest discover -s "tests" -p "*_test.py" -t "."
- A specific unit test:
coverage run -m unittest -v 'tests.unit.fibonacci_test.Fibo_Test.test_callWithValidInput_0'
- All the unit tests:
- Generate the coverage results:
coverage report
Text version of the coverage resultscoverage report --format=total
Total coverage result (no details)coverage lcov
Will generate anlcov.info
file that will be processed byCoverage Gutters
extension inVisual Studio Code
..vscode/settings.json
is configured accordingly.coverage html
Will generate an HTML version of the coverage results. You may access those from<repo>/htmlcov/index.html
.
flake8
is part the installed packages, you just need to:
- run
flake8
on the repo:
python -m flake8 .
- Check if any error has been reported.
You may also access flake8
from VSCode if you installed flake 8 extension
- Install VSCode:
https://code.visualstudio.com/- Install Python extension: ([REQUIRED] to run/debug)
https://marketplace.visualstudio.com/items?itemName=ms-python.python - Install Python formatter: ([REQUIRED] to edit code)
https://marketplace.visualstudio.com/items?itemName=ms-python.autopep8 - Install Python Linter: ([REQUIRED] to edit code)
https://marketplace.visualstudio.com/items?itemName=ms-python.flake8 - Install command variable: (Used for some configurations in
launch.json
)[OPTIONAL]
https://marketplace.visualstudio.com/items?itemName=rioj7.command-variable - Install TODO extension to see pending work: [OPTIONAL]
https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree - Display test coverage results on files: [OPTIONAL]
https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
- Install Python extension: ([REQUIRED] to run/debug)
- Keep track of your dependencies:
pip list
List all the installed dependencies...meaning all the dependencies you've explicitly installed and their implicit dependencies)pip freeze
Same aspip list
, but respecting the requirements file format
- Update dependencies
Edit therequirements.txt
file. Only add the explicit dependency you need, not their internal/recursive dependencies. To not lose your sanity, you may want to install pip-chill and/or pipdeptree. - Check if your dependencies have all they need:
pip check
- Want to start with a clean slate:
pip freeze > clean_dependencies.txt
pip uninstall -r clean_dependencies.txt -y