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
160
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
120
Crowd funded free software
pfctdayelise
0
72
Dynamic visualisation in the IPython Notebook
pfctdayelise
0
140
Zookeepr: home grown conference management software
pfctdayelise
0
81
Why "gender" should be a text field
pfctdayelise
0
100
Distributed wikis
pfctdayelise
0
77
Neurosexism
pfctdayelise
0
180
Clash of the encyclopedias: is competition good for sharing?
pfctdayelise
0
71
Language sleuthing HOWTO
pfctdayelise
0
93
Other Decks in Technology
See All in Technology
Algyan イベント振り返り
linyixian
0
200
The CloudCompare project by Dr. Daniel Girardeau-Montaut
kentaitakura
0
520
HEXA OSINT CTF V3 作戦会議
meow_noisy
0
120
EMとして2023年度に頑張ったこと / What we did well in FY2023 as a EM
pauli
1
130
Terraformあれやこれ/terraform-this-and-that
emiki
8
1.3k
4年前、あるじゃん老害エンジニアLT合戦に登壇、米国西海岸コンピュータ歴史博物館体験記の続編
toshi_atsumi
0
220
ChatGPT for IT Service Management (IT Pro)
dahatake
7
1.4k
AWS を使う上で知っておきたいオンプレミス知識/aws-on-premise-essentials
emiki
1
4.3k
アクセス制御にまつわる改善 / Improving access control
itkq
0
440
Hands-on / Kaname Frusawa / Cloud Compare Users Meetup 2024 at University of Tokyo on April 17
paraworld
2
480
Google Cloud の AI を支える裏側のインフラを垣間見る!
maroon1st
0
320
Compose Compiler Metricsを使った実践的なコードレビュー
tomorrowkey
1
210
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
The Illustrated Children's Guide to Kubernetes
chrisshort
30
46k
Debugging Ruby Performance
tmm1
70
11k
YesSQL, Process and Tooling at Scale
rocio
163
13k
No one is an island. Learnings from fostering a developers community.
thoeni
15
2.1k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
Optimizing for Happiness
mojombo
370
69k
The Language of Interfaces
destraynor
151
23k
KATA
mclloyd
14
12k
What's new in Ruby 2.0
geeforr
337
31k
Docker and Python
trallard
33
2.7k
BBQ
matthewcrist
80
8.8k
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