Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Funcargs and other fun with pytest

Funcargs and other fun with pytest

Presented at PyCon AU 2012.

Brianna Laugher

August 18, 2012
Tweet

More Decks by Brianna Laugher

Other Decks in Technology

Transcript

  1. pytest – all the good stuff ✔ all test styles:

    unittest, doctest, nose ✔ boilerplate-free style – natural asserts ✔ support for running tests distributed, boxed ✔ generate JUnit-style XML for Jenkins CI ✔ informative error reporting ✔ extensible plugins, useful builtins ✔ skip, xfail, custom markers ✔ parametrize, generate tests ✔ monkeypatch ✔ funcargs!
  2. my background • using pytest seriously for ~18 months at

    work • really enjoying it! • how it feels to use pytest: →
  3. Graphical Forecast Editor • client/server desktop application used by forecasters

    to generate the (text & graphical) forecasts • pilot in VIC, funding to roll out nationally, ~5 year project, 20+ new devs/testers • existing codebase of Python and C++ (used operationally in US) • home-grown test suite and runner (via GUI)
  4. generate tests • defined once per module • list/generate data

    to supply to 1+ tests • way more flexible cf. py.test.mark.parametrize
  5. funcargs – why? • dependency injection, aka inversion of control

    • works a treat with TDD • very natural with mocking • encourages modular design
  6. pytest – all the good stuff ✔ all test styles:

    unittest, doctest, nose ✔ boilerplate-free style – natural asserts ✔ support for running tests distributed, boxed ✔ generate JUnit-style XML for Jenkins CI ✔ informative error reporting ✔ extensible plugins, useful builtins ✔ skip, xfail, custom markers ✔ parametrize, generate tests ✔ monkeypatch ✔ funcargs!
  7. credits, thanks, contact Comic panels from comicallyvintage.tumblr.com Bureau of Meteorology

    • In particular, Darius Powell introduced pytest to our project Code examples: gist.github.com/3386951 [email protected] brianna.laugher.id.au / [email protected] @pfctdayelise