$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Funcargs and other fun with pytest
Search
Brianna Laugher
August 18, 2012
Technology
0
260
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
220
Crowd funded free software
pfctdayelise
0
180
Dynamic visualisation in the IPython Notebook
pfctdayelise
0
250
Zookeepr: home grown conference management software
pfctdayelise
0
180
Why "gender" should be a text field
pfctdayelise
0
240
Distributed wikis
pfctdayelise
0
180
Neurosexism
pfctdayelise
0
300
Clash of the encyclopedias: is competition good for sharing?
pfctdayelise
0
180
Language sleuthing HOWTO
pfctdayelise
0
220
Other Decks in Technology
See All in Technology
研究開発×プロダクトマネジメントへの挑戦 / ly_mlpm_meetup
sansan_randd
0
100
[JAWS-UG 横浜支部 #91]DevOps Agent vs CloudWatch Investigations -比較と実践-
sh_fk2
1
250
Haskell を武器にして挑む競技プログラミング ─ 操作的思考から意味モデル思考へ
naoya
6
1.3k
品質のための共通認識
kakehashi
PRO
3
230
意外とあった SQL Server 関連アップデート + Database Savings Plans
stknohg
PRO
0
300
Reinforcement Fine-tuning 基礎〜実践まで
ch6noota
0
160
Lambdaの常識はどう変わる?!re:Invent 2025 before after
iwatatomoya
1
420
re:Inventで気になったサービスを10分でいけるところまでお話しします
yama3133
1
120
プロダクトマネージャーが押さえておくべき、ソフトウェア資産とAIエージェント投資効果 / pmconf2025
i35_267
2
590
eBPFとwaruiBPF
sat
PRO
4
2.5k
Microsoft Agent 365 を 30 分でなんとなく理解する
skmkzyk
1
1k
Gemini でコードレビュー知見を見える化
zozotech
PRO
1
240
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Building Flexible Design Systems
yeseniaperezcruz
330
39k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
It's Worth the Effort
3n
187
29k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.3k
Code Reviewing Like a Champion
maltzj
527
40k
Embracing the Ebb and Flow
colly
88
4.9k
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