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
Introduction to pytest
Search
Andreas Pelme
July 23, 2014
Programming
1.1k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to pytest
Slides for my EuroPython 2014 talk on pytest
Andreas Pelme
July 23, 2014
More Decks by Andreas Pelme
See All by Andreas Pelme
pytest: helps you write better Django apps
pelme
5
970
Testing Django applications with py.test (EuroPython 2013)
pelme
2
3.1k
Testing applications Django with py.test (Django Stockholm meetup)
pelme
7
580
Other Decks in Programming
See All in Programming
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
4
1.3k
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
1.6k
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.9k
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
120
残高管理から台帳サービスへの進化
artoy
1
220
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
290
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
120
R8 の設定見直しでアプリサイズ削減
andpad
0
230
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.4k
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.9k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
250
Modernizing iOS Apps
seyfoyun
0
120
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
580
Color Theory Basics | Prateek | Gurzu
gurzu
1
500
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
720
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
A Soul's Torment
seathinner
8
3.8k
How STYLIGHT went responsive
nonsquared
100
6.3k
My Coaching Mixtape
mlcsv
0
370
Git: the NoSQL Database
bkeepers
PRO
433
67k
How GitHub (no longer) Works
holman
316
150k
Amusing Abliteration
ianozsvald
1
360
Music & Morning Musume
bryan
48
7.5k
Fireside Chat
paigeccino
43
4.1k
Transcript
*OUSPEVDUJPOUPQZUFTU "OESFBT1FMNF &VSP1ZUIPO 4MJEFTIUUQTQFBLFSEFDLDPNQFMNF personalkollen
5PQJDT w*OUSPEVDUJPO w5FTUJOHXJUIMFTTCPJMFSQMBUF w1MVHJOT w5FTUEJTDPWFSZ w1ZUFTUpYUVSFT w1PSUJOHFYJTUJOHQSPKFDUT
5FTUJOH
BGVMMGFBUVSFE1ZUIPOUFTUJOHUPPM QZUFTU
None
5FTUTXJUIMFTTCPJMFSQMBUF
%FNPUJNF
%FNP#FGPSF import unittest ! ! def upper_reverse(text):
return ''.join(reversed(text.upper())) ! ! class TestUpperReverse(unittest.TestCase): def test_upper_reverse(self): self.assertEqual(upper_reverse('hello'), 'OLLEH')
%FNP"GUFS def upper_reverse(text): return ''.join(reversed(text.upper()))
! ! def test_upper_reverse(): assert upper_reverse('hello') == 'OLLEH'
%FNPUJNF w"TTFSUJPOTXJUIQMBJOBTTFSUTUBUFNFOU w4VCDMBTTJOH5FTU$BTFJTOPUSFRVJSFE w5FTUTBSFGPVOEBOEDPMMFDUFEXJUIUIF QZUFTUDPNNBOE
1MVHJOT w%JTUSJCVUFEQBSBMMFMJ[FEQZUFTUYEJTU w%KBOHPQZUFTUEKBOHP w5XJTUFEQZUFTUUXJTUFE w-PHDBQUVSFQZUFTUDBQUVSFMPH w$PWFSBHFSFQPSUJOHQZUFTUDPW wBOENBOZNPSF wIUUQQZUFTUPSHMBUFTUQMVHJOTIUNMFYUFSOBMQMVHJOT
3VOOJOHUIFUFTUT
3VOUIFFOUJSFUFTUTVJUF $ py.test
3VOBMMUFTUTJOBTQFDJpDpMF $ py.test test_bar.py
3VOBMMUFTUDBTFTUIBUBSFOBNFE UFTU@GPP $ py.test -‐k test_foo
#ZEFGBVMU QZUFTUEJTDPWFSTUFTUTJO test_*.py *_test.py
.BSLJOHUFTUT ZPVDBONBLFVQZPVSPXONBSLFST import pytest ! ! @pytest.mark.slow def
test_very_long_running_test(): pass
3VOBMMUFTUTXJUIBTQFDJpDNBSLFS $ py.test -‐m slow
PSXJUIPVUBTQFDJpDNBSLFS $ py.test -‐m "not slow"
4LJQQJOHUFTUT import pytest import sys ! ! @pytest.mark.skipif(sys.platform
== 'darwin', reason='Feature Y not supported on OS X') def test_non_osx(): pass
%FQFOEFODZJOKFDUJPOPGUFTUpYUVSFT QZUFTUpYUVSFT
%FNPUJNF
%FQFOEFODZJOKFDUJPOPGUFTUIFMQFS import pytest from selenium.webdriver import Firefox !
@pytest.fixture def webdriver(request): driver = Firefox() request.addfinalizer(driver.quit) return driver ! def test_nix_website_title(webdriver): webdriver.get('https://nixos.org/nix/') assert 'Nix' in webdriver.title ! def test_pytest_website_title(webdriver): webdriver.get('http://pytest.org/latest/')
3VOUFTUTJOGPVSQSPDFTTFT $ pip install pytest-‐xdist $ py.test -‐n 4
VOJUUFTU /PTFTUZMFBOE%KBOHPUFTUTBSFTVQQPSUFE 1PSUJOHBOFYJTUJOHQSPKFDU
"EWBODFE6TFTPGQZUFTU'JYUVSFT 'MPSJT#SVZOPPHIF "! UPEBZ ! *NQSPWJOHZPVSBVUPNBUFEUFTUJOHXJUIQZUFTU )PMHFS,SFLFM ""!'SJEBZ %PO`UNJTT
&NBJMBOESFBT!QFMNFTF 5XJUUFS!BOESFBTQFMNF *3$QFMNF!QZMJCPO'SFFOPEF 4MJEFTIUUQTQFBLFSEFDLDPNQFMNF 2VFTUJPOT