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
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
360
Refactoring: la méthode Mikado
ronnix
0
270
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
430
Introduction au Customer Development
ronnix
1
150
Rendez votre code Python plus beau !
ronnix
1
570
Trompez-vous, et vite !
ronnix
2
310
Other Decks in Programming
See All in Programming
Your Perfect Project Setup for Angular @BASTA! 2025 in Mainz
manfredsteyer
PRO
0
130
Advance Your Career with Open Source
ivargrimstad
0
340
いま中途半端なSwift 6対応をするより、Default ActorやApproachable Concurrencyを有効にしてからでいいんじゃない?
yimajo
2
340
プログラマのための作曲入門
cheebow
0
540
Serena MCPのすすめ
wadakatu
4
900
iOSアプリの信頼性を向上させる取り組み/ios-app-improve-reliability
shino8rayu9
0
150
CI_CD「健康診断」のススメ。現場でのボトルネック特定から、健康診断を通じた組織的な改善手法
teamlab
PRO
0
180
Pull-Requestの内容を1クリックで動作確認可能にするワークフロー
natmark
2
450
ソフトウェア設計の実践的な考え方
masuda220
PRO
3
480
ABEMAモバイルアプリが Kotlin Multiplatformと歩んだ5年 ─ 導入と運用、成功と課題 / iOSDC 2025
akkyie
0
330
大規模アプリのDIフレームワーク刷新戦略 ~過去最大規模の並行開発を止めずにアプリ全体に導入するまで~
mot_techtalk
0
380
CSC305 Lecture 01
javiergs
PRO
1
400
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
114
20k
A better future with KSS
kneath
239
17k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
19
1.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
KATA
mclloyd
32
15k
The Power of CSS Pseudo Elements
geoffreycrofte
79
6k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
890
Why Our Code Smells
bkeepers
PRO
339
57k
Balancing Empowerment & Direction
lara
4
680
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6.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 !