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
Testing Django with Travis CI
Search
Adam McKerlie
November 11, 2012
Technology
760
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Testing Django with Travis CI
A talk I gave on testing Django and using Travis CI for Pycon Canada
Adam McKerlie
November 11, 2012
More Decks by Adam McKerlie
See All by Adam McKerlie
Getting Rid of Technical Debt
silent1mezzo
0
1.8k
Lessons Learned from a Re(design|write)
silent1mezzo
2
6.3k
Travis CI
silent1mezzo
7
4.6k
Other Decks in Technology
See All in Technology
今こそ聞きたいソフトウェア設計 ドメイン駆動設計再入門
masuda220
PRO
17
7.5k
事業価値と Engineering 2026年度版
recruitengineers
PRO
50
24k
【CEDEC2026】コードレビュー支援ツール開発から学ぶ:LLMを用いた業務システムの実践的な運用設計と誤出力対策
cygames
PRO
0
840
攻撃と防御で学ぶAI時代のプロダクトセキュリティ演習
recruitengineers
PRO
9
2.9k
修正PRを食べてレビュースキルが賢くなる:Claude Codeによる自己改善サイクル
yuyaumetsu
6
1.6k
MIRU 2026 チュートリアル
keisuke198619
0
960
【CEDEC2026】Creative Approaches to Localizing the Dialects and Unique Speech of Umamusume: Pretty Derby Characters in English
cygames
PRO
3
24k
メルカリのグローバルアプリで挑んだ AlloyDB 運用と課題解決の実践記
hatappi
0
250
【CEDEC2026】次世代デジタルカードゲームのサーバー設計と運用 〜『Shadowverse: Worlds Beyond』の舞台裏~
cygames
PRO
1
1.4k
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
なぜ Temporal の大小比較には compare しかないのか / Why Does Temporal Only Have compare() for Comparisons
kazukihayase
1
140
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
220
Featured
See All Featured
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
530
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
370
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
240
Practical Orchestrator
shlominoach
191
12k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
670
Code Reviewing Like a Champion
maltzj
528
40k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
470
So, you think you're a good person
axbom
PRO
2
2.1k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
990
Transcript
TESTING DJANGO WITH TRAVIS CI 1 Sunday, November 11, 12
• Python Developer at • Twitter: @adammckerlie • Everywhere else:
silent1mezzo ABOUT ME 2 Sunday, November 11, 12
SLIDES bit.ly/UhvbjV 3 Sunday, November 11, 12
• Definitions • Why you should test your code •
What parts of your code you should test • Writing your first test • Integrating Travis CI to automatically run your tests OVERVIEW 4 Sunday, November 11, 12
UNIT TEST • Tests one small section of code •
Focuses your code • Fast 5 Sunday, November 11, 12
INTEGRATION TEST • Tests that the whole system works (views,
forms, etc...) • Slow • Gives you a full picture of what’s happening 6 Sunday, November 11, 12
• Gives you confidence in your code • Allows you
to iterate faster • Provides beginners an easy spot to code-dive • Untested code is expensive WHY YOU SHOULD WRITE TESTS 7 Sunday, November 11, 12
“CODE NOT TESTED IS BROKEN BY DESIGN” JACOB KAPLAN-MOSS 8
Sunday, November 11, 12
• Don’t test Django or Python’s built-in stuff • Test
your views, models, forms, management commands, etc... WHAT YOU SHOULD TEST 9 Sunday, November 11, 12
• Tests can go in models.py or tests.py • Must
subclass django.test.TestCase • python manage.py test <app_name> WRITING YOUR FIRST TEST 10 Sunday, November 11, 12
• Every view should have this test 11 Sunday, November
11, 12
• Fixtures are serialized data that you can load. •
python manage.py dumpdata app_name > app_name/fixtures/file.json USING FIXTURES 12 Sunday, November 11, 12
13 Sunday, November 11, 12
• After every commit • Before you merge your branches
into master • Once you’ve deployed your code WHEN SHOULD YOU TEST 14 Sunday, November 11, 12
WHAT IS TRAVIS-CI? • Continuous Integration Testing • Open Source
• https://github.com/travis-ci 15 Sunday, November 11, 12
+ = 16 Sunday, November 11, 12
HOW DOES IT WORK? • Sign up with your github
account • Specify repositories • Include a .travis.yml file • Change/commit/push code • Tests run automagically 17 Sunday, November 11, 12
18 Sunday, November 11, 12
.travis.yml 19 Sunday, November 11, 12
Environment Variables 20 Sunday, November 11, 12
Using Databases 21 Sunday, November 11, 12
PULL REQUESTS • Test Pull Requests before they’re merged to
master • Notifications of running tests • Notifications of successful tests 22 Sunday, November 11, 12
23 Sunday, November 11, 12
24 Sunday, November 11, 12
before/after_script 25 Sunday, November 11, 12
NOTIFICATIONS 26 Sunday, November 11, 12
Email Notifications 27 Sunday, November 11, 12
IRC Notifications 28 Sunday, November 11, 12
Webhook Notifications 29 Sunday, November 11, 12
FINAL TIPS • [ci skip] • https://secure.travis-ci.org/[YOUR_GITHUB_USERNAME]/ [YOUR_PROJECT_NAME].png • travis-lint
30 Sunday, November 11, 12
QUESTIONS? 31 Sunday, November 11, 12