Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Techniques de test avancées en Python
Search
Ronan Amicel
September 23, 2017
Programming
0
330
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
330
Performance des frameworks web : Python vs The World
ronnix
0
440
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
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
130
Combinatorial Interview Problems with Backtracking Solutions - From Imperative Procedural Programming to Declarative Functional Programming - Part 2
philipschwarz
PRO
0
120
開発に寄りそう自動テストの実現
goyoki
2
1.4k
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
590
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
780
これならできる!個人開発のすゝめ
tinykitten
PRO
0
130
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
180
PC-6001でPSG曲を鳴らすまでを全部NetBSD上の Makefile に押し込んでみた / osc2025hiroshima
tsutsui
0
190
Java 25, Nuevas características
czelabueno
0
120
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
300
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
440
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
130
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
The Cost Of JavaScript in 2023
addyosmani
55
9.4k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
150
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.7k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
How STYLIGHT went responsive
nonsquared
100
6k
Amusing Abliteration
ianozsvald
0
71
GraphQLとの向き合い方2022年版
quramy
50
14k
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 !