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
Ronan Amicel
September 23, 2017
Programming
360
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Techniques de test avancées en Python
Présentation à la conférence PyCon FR à Toulouse le 23 octobre 2017.
Ronan Amicel
September 23, 2017
More Decks by Ronan Amicel
See All by Ronan Amicel
Développeur : ce qu’on ne m’a pas appris à l’école
ronnix
1
410
Refactoring: la méthode Mikado
ronnix
0
290
Product Development in a Startup
ronnix
2
280
Performance des frameworks web : Python vs The World (v1.1)
ronnix
1
8.4k
Je teste mon code avec py.test
ronnix
1
370
Performance des frameworks web : Python vs The World
ronnix
0
480
Introduction au Customer Development
ronnix
1
170
Rendez votre code Python plus beau !
ronnix
1
590
Trompez-vous, et vite !
ronnix
2
320
Other Decks in Programming
See All in Programming
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
120
仕様駆動開発の消費期限
watany
20
9.2k
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
150
MySQLとPostgreSQLって何が違うの?
akagami
0
150
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
130
T3DD26: From RAGs to Riches
martinhelmich
0
130
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.3k
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
170
源内ハンズオン概要編
hideg
0
230
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
140
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
280
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
850
Featured
See All Featured
New Earth Scene 8
popppiees
3
2.5k
Everyday Curiosity
cassininazir
0
300
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Between Models and Reality
mayunak
4
430
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
510
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
240
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Practical Orchestrator
shlominoach
191
12k
Technical Leadership for Architectural Decision Making
baasie
3
550
Rails Girls Zürich Keynote
gr2m
96
14k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
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 !