Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Funcargs and other fun with pytest
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Brianna Laugher
August 18, 2012
Technology
0
270
Funcargs and other fun with pytest
Presented at PyCon AU 2012.
Brianna Laugher
August 18, 2012
Tweet
Share
More Decks by Brianna Laugher
See All by Brianna Laugher
Realities of open source testing: Lessons learned from Adopt Pytest Month
pfctdayelise
0
230
Crowd funded free software
pfctdayelise
0
180
Dynamic visualisation in the IPython Notebook
pfctdayelise
0
260
Zookeepr: home grown conference management software
pfctdayelise
0
180
Why "gender" should be a text field
pfctdayelise
0
250
Distributed wikis
pfctdayelise
0
190
Neurosexism
pfctdayelise
0
300
Clash of the encyclopedias: is competition good for sharing?
pfctdayelise
0
190
Language sleuthing HOWTO
pfctdayelise
0
220
Other Decks in Technology
See All in Technology
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
970
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
620
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
180
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
670
M&A 後の統合をどう進めるか ─ ナレッジワーク × Poetics が実践した組織とシステムの融合
kworkdev
PRO
1
480
AIエージェントに必要なのはデータではなく文脈だった/ai-agent-context-graph-mybest
jonnojun
0
120
OWASP Top 10:2025 リリースと 少しの日本語化にまつわる裏話
okdt
PRO
3
820
SRE Enabling戦記 - 急成長する組織にSREを浸透させる戦いの歴史
markie1009
0
130
Context Engineeringの取り組み
nutslove
0
370
Tebiki Engineering Team Deck
tebiki
0
24k
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.5k
Featured
See All Featured
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
920
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
Google's AI Overviews - The New Search
badams
0
910
Prompt Engineering for Job Search
mfonobong
0
160
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
97
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Tell your own story through comics
letsgokoyo
1
810
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
130
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
330
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
Transcript
PyCon AU 2012 Brianna Laugher funcargs & other fun with
pytest
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!
None
my background • using pytest seriously for ~18 months at
work • really enjoying it! • how it feels to use pytest: →
None
None
None
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)
None
informative error reporting
informative error reporting
extensible • e.g. add in unittest assert methods
extensible • e.g. add hook for winpdb
None
skip
xfail
custom markers
None
parametrize
None
generate tests • defined once per module • list/generate data
to supply to 1+ tests • way more flexible cf. py.test.mark.parametrize
generate generators!
None
monkeypatch
None
None
None
None
funcargs!
funcargs – idealised db example
funcargs – trivial django example
funcargs – trivial GAE examples
funcargs – trivial GAE examples
None
funcargs – why? • dependency injection, aka inversion of control
• works a treat with TDD • very natural with mocking • encourages modular design
None
funcargs – a real DB example
funcargs – a real DB example
funcargs – to express prereq's • for when a decorator
is not powerful enough
None
funcargs – to hide monkeypatch :)
None
generate + funcarg - anypython
None
None
pytest – the future
None
test evolution -v0
None
test evolution - v1
test evolution - v2
test evolution – v3
test evolution - v4
None
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!
None
None
• http://codespeak.net/mailman/listinfo/py-dev • testing-in-python mailing list • Stack Overflow •
lead developer Holger Krekel is very responsive
pytest.org
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