Skip to main content
Web Fundamentals: Assignment 1 is due at the end of week 2.
My College
On this page

Lab 1

Step 4 of 4

Testing

Verify the todo commands with automated tests.

Write tests for the todo commands. Replace this with your step instructions.

Instructions

  1. Install pytest with python -m pip install pytest
  2. Create test_todo.py and test the add and list commands
  3. Run pytest and verify all tests pass

Write the test

pytest runs every function named test_* in files named test_*.py. A plain assert statement reports the failure:

Pythontest_todo.py
def test_add_todo():
todos = []
todos.append("write tests")
assert len(todos) == 1

Run the tests:

Terminal
$ python -m pytest
1 passed in 0.01s

Last updated: