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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
390
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.3k
Je teste mon code avec py.test
ronnix
1
360
Performance des frameworks web : Python vs The World
ronnix
0
470
Introduction au Customer Development
ronnix
1
160
Rendez votre code Python plus beau !
ronnix
1
590
Trompez-vous, et vite !
ronnix
2
320
Other Decks in Programming
See All in Programming
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
Performance Engineering for Everyone
elenatanasoiu
0
200
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
AI 輔助遺留系統現代化的經驗分享
jame2408
1
910
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
800
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.9k
dRuby over BLE
makicamel
2
380
Vite+ Unified Toolchain for the Web
naokihaba
0
330
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
110
OSもどきOS
arkw
0
580
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
210
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
290
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
270
Bash Introduction
62gerente
615
220k
It's Worth the Effort
3n
188
29k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
490
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
630
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Prompt Engineering for Job Search
mfonobong
0
350
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
220
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
250
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 !