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
350
0
Share
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
280
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
350
Performance des frameworks web : Python vs The World
ronnix
0
460
Introduction au Customer Development
ronnix
1
160
Rendez votre code Python plus beau !
ronnix
1
580
Trompez-vous, et vite !
ronnix
2
320
Other Decks in Programming
See All in Programming
AI時代になぜ書くのか
mutsumix
0
360
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
AWSはOSSをどのように 考えているのか?
akihisaikeda
0
110
AgentCore Optimizationを始めよう!
licux
3
230
Programming with a DJ Controller — not vibe coding
m_seki
3
820
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.6k
実用!Hono RPC2026
yodaka
2
310
認証統合から始めるフロントエンドの機能単位開発 — マイクロサービス思想の適用
koukimiura
0
100
Agentic Elixir
whatyouhide
0
450
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
340
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
410
AIを導入する前にやるべきこと
negima
2
340
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
120
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
Abbi's Birthday
coloredviolet
2
7.5k
Google's AI Overviews - The New Search
badams
0
1k
Marketing to machines
jonoalderson
1
5.2k
The Pragmatic Product Professional
lauravandoore
37
7.3k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
330
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Color Theory Basics | Prateek | Gurzu
gurzu
0
310
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 !