Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Funcargs and other fun with pytest
Brianna Laugher
August 18, 2012
Technology
0
110
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
66
Crowd funded free software
pfctdayelise
0
28
Dynamic visualisation in the IPython Notebook
pfctdayelise
0
81
Zookeepr: home grown conference management software
pfctdayelise
0
35
Why "gender" should be a text field
pfctdayelise
0
44
Distributed wikis
pfctdayelise
0
37
Neurosexism
pfctdayelise
0
100
Clash of the encyclopedias: is competition good for sharing?
pfctdayelise
0
31
Language sleuthing HOWTO
pfctdayelise
0
39
Other Decks in Technology
See All in Technology
AWS re:Invent 2022で発表された新機能を試してみた ~Cloud OperationとSecurity~ / New Cloud Operation and Security Features Announced at AWS reInvent 2022
yuj1osm
1
210
AI Services 概要 / AI Services overview
oracle4engineer
PRO
0
170
NGINXENG JP#2 - 4-NGINX-エンジニアリング勉強会
hiropo20
0
120
書籍を書きました。 そう、VS Codeで。
takumanakagame
4
4.5k
Raspberry Pi Camera 3 介紹
piepie_tw
PRO
0
150
Deep dive in Reserved Instance ~脳死推奨量購入からの脱却~
kzkmaeda
0
540
目指せCoverage100%! AutoScale環境におけるSavings Plans購入戦略 / JAWS-UG_SRE_Coverage
taishin
0
510
Exploring MapStore Release 2022.02: improved 3DTiles support and more
simboss
PRO
0
370
創業1年目のスタートアップでAWSコストを抑えるために取り組んでいること / How to Keep AWS Costs Down at a Startup
yuj1osm
3
2.2k
SPA・SSGでSSRのようなOGP対応!
simo123
2
150
地方自治体業務あるある ーアナログ最適化編-
y150saya
1
270
Oracle Cloud Infrastructure:2023年1月度サービス・アップデート
oracle4engineer
PRO
0
160
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
152
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
217
21k
Clear Off the Table
cherdarchuk
79
290k
Mobile First: as difficult as doing things right
swwweet
213
7.8k
How STYLIGHT went responsive
nonsquared
89
4.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.5k
Navigating Team Friction
lara
177
12k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
10
1.3k
The World Runs on Bad Software
bkeepers
PRO
59
5.7k
Happy Clients
brianwarren
90
5.8k
Six Lessons from altMBA
skipperchong
15
2.3k
Atom: Resistance is Futile
akmur
256
24k
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