← Back to mit.katmh.com

Testing and Debugging Programs

· Read 02/24/21

pytest exepcted to be able to evaluate all the code first, and then run the function

Gather information

  • pytest
  • Print statements: #1 tool

Narrow our focus

  • Less data
  • Less code

Stay focused on this bug

At some point, someone made an assumption (e.g. about how a function works, about how data will be provided) that was wrong

Mutated input, multiple aliases

Bug is when code doesn't meet specifications

[::-1] to reverse

zip object is some object on the heap

Pull it out with list(zip())

[a - b for a, b in zip(l1, l2)]

Hehe instructor asked for the "fancy software engineering term" refactoring and I said it in the chat

Defensive programming, fail fast