Contribute Media
A thank you to everyone who makes this possible: Read More

Pro tips for writing great unit tests

Description

Pro tips for writing great unit tests - PyCon Italia 2022

There is an art to condensing test concepts into readable, fast, clear predicates.

  • We look at many examples and show how they can be improve
  • Master the use of any() and all() with generator expressions.
  • Expression set() relations to express big ideas clearly.
  • Cover the problem space with combinatoric iterators: product(), combinations(), permutations()
  • Use subtests for clear error reporting
  • Factor-out data acquisition and parsing from the test predicates.
  • Learn patterns for testing edge cases.
  • Cover class based technique for test reuse.
  • Make effective use of setup and teardown.
  • We look at many examples and show how they can be improved
  • Treating TDD test cases and bug test cases with special reverence.

Speaker: Raymond Hettinger

Details

Improve this page