Nov 30: Quiz 6A and PA 3
Learning Objectives
After today's class, you should be able to:
- Learn more about JSON files
- Review of pytest
Lesson Outline¶
- Recall JSON example
- CORGIS JSON files and
load()
result in a list of dictionaries - Some useful list functions:
apppend(value)
sort(list)
sorts the given list orlist.sort()
sorted(list)
returns a sorted list orlist.sorted()
- note
sorted(collection)
can be used for sequences and collections
- note
min(list)
returns min valuemax(list)
return max valuesum(list)
returns the sumlen(list)
returns the length
Quiz 6A: 25 minutes
- Log in as
student
on the lab machine - Open web browser, go to canvas and log in with your eid
- In canvas, go to Modules, Quiz6A
- Do part one of the Module
- The programming portion is given on sheet of paper
- Open Thonny
- Submit work using Canvas with Gradesope, Module Quiz6A, Programming
PA 3
- JSON files
- two formats for the PA
- use of
load()
anddump()
- Overview
- Part B is due tonight at 11pm (8am Friday morning)
- Go over a few examples
- Recall pytest
VSCode Setup
If you haven't already, please work through the Visual Studio Code Setup instructions.
Follow these steps to configure pytest to run with test coverage:
- Open your PA3 folder in VSCode (not your CS149 folder).
- Open a Terminal and install the pytest-cov package:
- Run the command pip install pytest-cov.
- If pip doesn't work, try pip3, or python -m pip, or python3 -m pip.
- Run the command pip install pytest-cov.
- Press F1 to open the Command Pallette
- Type
work json
and pressEnter
.- This will create/open the file
.vscode/settings.json
in your PA3 folder.
- This will create/open the file
- Paste the following settings between the curly braces:
"python.testing.pytestArgs": [ "--cov=.", "--cov-branch", "--cov-report=term", "--cov-report=xml" ], "python.testing.pytestEnabled": true, "coverage-gutters.showGutterCoverage": false, "coverage-gutters.showLineCoverage": true
- Save and close the
settings.json
file. - Install the Coverage Gutters extension:
- Click the "Extensions" icon on the left sidebar
- Search for "Coverage Gutters" (by ryanluker)
To view coverage results, click the "Watch" button on the bottom left of VSCode.
Your To-Do List¶
Today
- Complete Part B of PA 3
- Three parts
- Readiness Quiz DONE
- Part B
- Due Thursday Nov 30th
- Part C
- Due Wednesday Dec 6th