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
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
Platform Engineering as a Product: Criteria for Improvement and Multi-Tenant Design
kumorn5s
0
460
もりもり新機能を一挙紹介! AgentCoreに入門して、AWS上にAIエージェントを構築しよう
minorun365
PRO
6
640
Java正規表現エンジン(NFA)の仕組みと パフォーマンスを維持するための最適化手法
takeuchi_132917
0
170
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
210
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
150
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
oracle-to-databricks-migration-with-llm-and-dbt
casek
1
400
Spring AI × MCP 入門〜AIエージェントへのツール公開、境界設計から始める最小構成 〜
yuyamiyamoto
0
200
Dynamic Workersについて
yusukebe
2
560
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
6
4.9k
先取りMaven4 ~16年ぶりのメジャーアップデート、その進化とは?~
ogiwarat
0
120
個人最適 から 全体最適 へ AI情報共有会・AIギルド・AI-DLC で進める カンリーの組織展開
rfdnxbro
0
180
Featured
See All Featured
Done Done
chrislema
186
16k
Embracing the Ebb and Flow
colly
88
5.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
KATA
mclloyd
PRO
35
15k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
540
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
270
Mind Mapping
helmedeiros
PRO
1
220
Ethics towards AI in product and experience design
skipperchong
2
290
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Navigating Weather and Climate Data
rabernat
0
210
RailsConf 2023
tenderlove
30
1.5k
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