Testing Python code with pytest

pytest

Notes

  • Slides

  • A little background about functional testing.

  • How to test the Meetup web site?

  • Very complex.

  • The difficulty to introduce testing late in the process.

  • Start simple, test a function.

    • mymath - add two numbers
    • how to use it from another file
    • the same way we test it
  • Copy paste it to multiply two numbers Show failure

  • Fixing the code or marking the test as "expected to fail"?

  • -rx

  • Warn about running code but not verifying it with assert

  • Fibonacci - exception

  • Verbose -v

  • print STDOUT -s

  • Stop on first failure -x --maxfail 42

Author

Gabor Szabo (szabgab)

Gabor Szabo, the author of the Python Maven web site.

Gabor Szabo