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
210
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
180
Crowd funded free software
pfctdayelise
0
130
Dynamic visualisation in the IPython Notebook
pfctdayelise
0
200
Zookeepr: home grown conference management software
pfctdayelise
0
130
Why "gender" should be a text field
pfctdayelise
0
180
Distributed wikis
pfctdayelise
0
130
Neurosexism
pfctdayelise
0
240
Clash of the encyclopedias: is competition good for sharing?
pfctdayelise
0
130
Language sleuthing HOWTO
pfctdayelise
0
160
Other Decks in Technology
See All in Technology
5分でわかるDuckDB
chanyou0311
10
3.3k
Google Cloud で始める Cloud Run 〜AWSとの比較と実例デモで解説〜
risatube
PRO
0
120
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
190
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
160
マイクロサービスにおける容易なトランザクション管理に向けて
scalar
0
190
OCI技術資料 : ファイル・ストレージ 概要
ocise
3
11k
メンタル面でもつよつよエンジニアになる/登壇資料(井田 献一朗)
hacobu
0
120
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
180
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
200
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
280
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
500
Wantedly での Datadog 活用事例
bgpat
2
680
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Building an army of robots
kneath
302
44k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Become a Pro
speakerdeck
PRO
26
5k
GitHub's CSS Performance
jonrohan
1031
460k
A Tale of Four Properties
chriscoyier
157
23k
Navigating Team Friction
lara
183
15k
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