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
740
Other Decks in Programming
See All in Programming
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
270
Getting Started with Vibe Coding
miccheng
0
150
オーケストレーション記述言語 Katari
yukikurage
0
220
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
320
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
300
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.5k
[2026-10-14](C)Re:ゼロから始める異世界生活〜始まりの終わりと終わりの始まり〜
tosite
0
260
最近”作らせてる” ローカルAIアプリの話
akit37
0
530
SODA - FACT BOOK(EN)
sodainc
1
200
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
7.1k
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
3
2.4k
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
610
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
520
Marketing to machines
jonoalderson
1
6k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
Exploring anti-patterns in Rails
aemeredith
4
560
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.7k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
460
Designing for Performance
lara
612
70k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
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