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
Brianna Laugher
August 18, 2012
Technology
0
230
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
190
Crowd funded free software
pfctdayelise
0
150
Dynamic visualisation in the IPython Notebook
pfctdayelise
0
210
Zookeepr: home grown conference management software
pfctdayelise
0
140
Why "gender" should be a text field
pfctdayelise
0
190
Distributed wikis
pfctdayelise
0
140
Neurosexism
pfctdayelise
0
250
Clash of the encyclopedias: is competition good for sharing?
pfctdayelise
0
140
Language sleuthing HOWTO
pfctdayelise
0
170
Other Decks in Technology
See All in Technology
20250309 無冠のわたし これからどう先生きのこれる?
akiko_pusu
11
2.2k
AIxIoTビジネス共創ラボ紹介_20250311.pdf
iotcomjpadmin
0
170
技術を育てる組織・組織を育てる技術 / technology and organization
motemen
10
3.8k
俯瞰と個別の⼆つの視点で紡ぐ スクラムマスターの成⻑と協働 / Dual Views Weaving Scrum Master Growth
toma_sm
1
120
Real World Nix CI/CD編
asa1984
1
210
StotybookからはじめるVRT -個人開発編-
arrow2nd
1
910
Roomの監視可能なクエリのカスタマイズとレガシーコードへの適用
shiita0903
2
160
組織のスケールを見据えたプロジェクトリードエンジニア制度の実践 / Project Lead Engineer for Scaling Engineering Organization
ohbarye
9
2.5k
x86-64 Assembly Essentials
latte72
4
1.1k
Scala meets WebAssembly
tanishiking
0
140
株式会社Awarefy(アウェアファイ)会社説明資料 / Awarefy-Company-Deck
awarefy
3
12k
I tried leaving the presentation to AI.
zzzzico
3
110
Featured
See All Featured
Bash Introduction
62gerente
611
210k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
It's Worth the Effort
3n
184
28k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Done Done
chrislema
182
16k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Adopting Sorbet at Scale
ufuk
75
9.3k
Gamification - CAS2011
davidbonilla
80
5.2k
The Cult of Friendly URLs
andyhume
78
6.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
8
680
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