git clone https://github.com/rharris-nitro/pythonExercise1.gitSee How To: Git for more info.
pip install pre-commit
cd pythonExercise1
pre-commit installSee All About Precommit Hooks for more info.
If you are using Homebrew, enter this into the command line:
brew install go-task/tap/go-taskFor more info, visit the Taskfile website
Install VSCode from here. After setting up, you should open the folder in VSCode in the directory where the repo is cloned.
-
Build and run a container using Task:
task build task up
You should see the output of your Python script:
my-python-app | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]-
Build and run a container using Task:
task up-test
You should see the output of your pytest test:
my-python-app | ============================= test session starts ==============================
my-python-app | platform linux -- Python 3.11.9, pytest-7.4.3, pluggy-1.5.0
my-python-app | rootdir: /pythonExercise1
my-python-app | collected 3 items
my-python-app |
my-python-app | tests/test_main.py ... [100%]
my-python-app |
my-python-app | ============================== 3 passed in 0.06s ===============================
my-python-app | Name Stmts Miss Cover
my-python-app | ----------------------------------------
my-python-app | app/__init__.py 0 0 100%
my-python-app | app/data.py 7 0 100%
my-python-app | tests/__init__.py 0 0 100%
my-python-app | tests/test_main.py 12 0 100%
my-python-app | ----------------------------------------
my-python-app | TOTAL 19 0 100%
my-python-app | Wrote HTML report to htmlcov/index.htmlThis shows the pytest on the first half, the coverage report on the second half, and the last line shows there is a nicer HTML format at the given folder path if you don't like the CLI report format
For more info about how pyTest works, visit Pytest for Absolute Beginners For more info on coverage.py, go to <coverage-testing.md>
To debug the main image in VSCode, run the image using task and set USE_DEBUG to true:
task up USE_DEBUGPY=trueThe same can be done for the test image (FYI: this can only debug unit test, not coverage test)
Go to the Run and Debug section in VSCode, make sure the Debugger is on Remote Attach, and press the green play button.
See <debugging.md> for more info