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
Techniques de test avancées en Python
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ronan Amicel
September 23, 2017
Programming
0
340
Techniques de test avancées en Python
Présentation à la conférence PyCon FR à Toulouse le 23 octobre 2017.
Ronan Amicel
September 23, 2017
Tweet
Share
More Decks by Ronan Amicel
See All by Ronan Amicel
Développeur : ce qu’on ne m’a pas appris à l’école
ronnix
1
370
Refactoring: la méthode Mikado
ronnix
0
280
Product Development in a Startup
ronnix
2
270
Performance des frameworks web : Python vs The World (v1.1)
ronnix
1
8.2k
Je teste mon code avec py.test
ronnix
1
340
Performance des frameworks web : Python vs The World
ronnix
0
450
Introduction au Customer Development
ronnix
1
150
Rendez votre code Python plus beau !
ronnix
1
580
Trompez-vous, et vite !
ronnix
2
310
Other Decks in Programming
See All in Programming
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
組織で育むオブザーバビリティ
ryota_hnk
0
170
CSC307 Lecture 06
javiergs
PRO
0
680
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
420
今から始めるClaude Code超入門
448jp
7
8.5k
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
100
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
970
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
450
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
610
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
540
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
170
Featured
See All Featured
First, design no harm
axbom
PRO
2
1.1k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
Designing for humans not robots
tammielis
254
26k
We Have a Design System, Now What?
morganepeng
54
8k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
Design in an AI World
tapps
0
140
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.6k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Writing Fast Ruby
sferik
630
62k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
300
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Transcript
Techniques de test avancées en Python Ronan Amicel @amicel PyCon
FR — 23 septembre 2017 — Toulouse
Ronan Amicel Développeur Consultant Coach technique Startups http://pocketsensei.fr/
Le plan 1. Contrôler l’exécution des tests 2. Mettre en
place le contexte 3. Paramétrer les tests 4. Vérifier ce qui s’est passé
0 Préambule : py.test
$ py.test • Un outil en ligne de commande pour
lancer vos tests : • découverte • exécution • affichage des résultats
import pytest • Un framework pour écrire vos tests •
avec très peu de bla bla • avec un mécanisme de fixtures très flexible
1 Techniques pour contrôler l’exécution des tests
Sélection
Exécuter tous les tests $ py.test
Exécuter seulement certains tests $ py.test tests/unit/ $ py.test toto.py
$ py.test --pyargs mon.module
Un test bien précis $ py.test fichier.py::fonction $ py.test fichier.py::Classe::methode
Seulement les tests dont le nom contient un mot-clé $
py.test -k toto $ py.test -k 'toto or tata'
Collecter les tests uniquement $ py.test --collect-only
Quand les tests sont au rouge
Lancer seulement les tests qui ont échoué la dernière fois
$ py.test --lf $ py.test --last-failed
Lancer d'abord les tests qui ont échoué la dernière fois
$ py.test --ff $ py.test --failed-first
S’arrêter à la première erreur $ py.test -x $ py.test
--exitfirst
Afficher les valeurs des variables locales $ py.test -l $
py.test --showlocals
Basculer sur le débogueur en cas d’erreur $ py.test --pdb
Combo ! $ py.test --ff -x -l --pdb
pytest.ini [pytest] addopts = --ff -x -l --pdb
Plugins
Lancer ses tests en parallèle $ pip install pytest-xdist $
py.test -n4
Couverture de tests $ pip install pytest-cov $ py.test --cov
myproj
tox
pyenv
2 Techniques pour mettre en place le contexte
3 Techniques pour paramétrer les tests
4 Techniques pour vérifier ce qui s'est passé
Voir les exemples sur GitHub https://github.com/ronnix/pyconfr2017/
En savoir plus http://pytest.org/ https://tox.readthedocs.io/ https://github.com/pyenv/pyenv http://hypothesis.readthedocs.io/
Questions ?
Merci !