Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Unit testing in python
Search
Gabriel Falcão
February 06, 2012
Programming
740
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unit testing in python
motivation, techniques and tools
Gabriel Falcão
February 06, 2012
More Decks by Gabriel Falcão
See All by Gabriel Falcão
Testing in Django
gabrielfalcao
8
730
Other Decks in Programming
See All in Programming
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
140
mrbgem 三角測量 開発
ogom
0
230
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
580
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
160
すこし踏み込む CancellationToken
htkym
2
1.7k
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
400
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
160
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
220
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
350
Simple Storage Service(S3) is not simple
iwatsukayura
0
250
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
200
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
770
Crafting Experiences
bethany
1
380
30 Presentation Tips
portentint
PRO
1
430
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Everyday Curiosity
cassininazir
0
350
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Become a Pro
speakerdeck
PRO
31
6.3k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Transcript
Unit testing motivation, techniques and tools
Past •Tests were written after the code was “ready” •Mocks,
Stubs, are also an old concept: isolate modules •Microsoft, Sun and other huge software companies were using since... ever
Hey wait... Microsoft Testing after written? +
coincidence?
Present •Kent Back changed the world •Google, Facebook, [your badass
company here] doing •Mocks, Stubs, now are less heavily used
Why is it cool ? •Automagic refactoring •Modules are isolated
•Code is cleaner •Modules are isolated •No more fear when changing code that is too important •They run just so fast •White box
Wait.... white box?!
White box •Comes from hacking/security vocabulary •The developer knows the
codebase in depth •Test relies on internal calls
Test-driven development How to start it
Baby steps
Baby steps •Don’t write the whole thing at once •The
next step will come naturally •Small units of code •The name is cute
The Mantra Red (1) Green (2) Refactor (3)
... in other words
YAGNI YOU AIN’T GONNA NEED IT ...at least for now.
YAGNI
YAGNI Focus on what you need to achieve now don’t
try to predict the future
Python Past/present/future?
Python - Past •unittest and unittest2 •class-based •camel case •overcomplicated
•the community wasn’t really into it •... so we didn’t have many libraries BORING...
Python - Past
None
Python - Present •Nose — •DSLs are growing and becoming
more popular •it is becoming fun to write tests •so that we’ll want to write more and more ROBUST CODE
Python - Present •Easier to write •conventions instead of classes
•libraries leveraging mocks and stubs
Old-school mocking and asserting
But now we are hipsters
and cool libraries does the hard job
What about stubs? •They’re just like mocks •But doesn’t have
behavior (no methods, just info)
What about stubs?
Future?!
Future?!
Future?!
Future?!
Django let’s have some fun
How it is •The default test support uses unittest2 •or
doctests •don’t separate between unit, functional, etc •which leverages having very slow suites •doesn’t provide support for isolation •kinda focused on black box
Unclebob •per app tests (unit, functional, integration) •isolate the database
so it fails if your test tries to use it •discover tests automagically
Unclebob http://bit.ly/woTgXq
testing huge views
None
None
the idea is simple
move logic into objects, testing each unit of logic separately
links •http://readthedocs.org/docs/nose/en/latest/ •http://github.com/gabrielfalcao/sure •http://github.com/gabrielfalcao/unclebob