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 or list.sort()
    • sorted(list) returns a sorted list or list.sorted()
      • note sorted(collection) can be used for sequences and collections
    • min(list) returns min value
    • max(list) return max value
    • sum(list) returns the sum
    • len(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() and dump()
  • 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:

  1. Open your PA3 folder in VSCode (not your CS149 folder).
  2. 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.
  3. Press F1 to open the Command Pallette
  4. Type work json and press Enter.
    • This will create/open the file .vscode/settings.json in your PA3 folder.
  5. 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
    
  6. Save and close the settings.json file.
  7. 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