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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Adam McKerlie
November 11, 2012
Technology
2
750
Testing Django with Travis CI
A talk I gave on testing Django and using Travis CI for Pycon Canada
Adam McKerlie
November 11, 2012
Tweet
Share
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
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
130
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
5.5k
AWS Network Firewall Proxyを触ってみた
nagisa53
1
240
What happened to RubyGems and what can we learn?
mikemcquaid
0
300
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
250
StrandsとNeptuneを使ってナレッジグラフを構築する
yakumo
1
120
[CV勉強会@関東 World Model 読み会] Orbis: Overcoming Challenges of Long-Horizon Prediction in Driving World Models (Mousakhan+, NeurIPS 2025)
abemii
0
140
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
1
370
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
470
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
3
1.5k
データの整合性を保ちたいだけなんだ
shoheimitani
8
3.1k
Featured
See All Featured
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
130
Game over? The fight for quality and originality in the time of robots
wayneb77
1
120
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Crafting Experiences
bethany
1
49
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
180
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Producing Creativity
orderedlist
PRO
348
40k
Mobile First: as difficult as doing things right
swwweet
225
10k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Context Engineering - Making Every Token Count
addyosmani
9
660
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