tech:python_tests_unitaires
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:python_tests_unitaires [2025/09/05 14:55] – Jean-Baptiste | tech:python_tests_unitaires [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Python tests unitaires | ||
| + | |||
| + | Voir aussi: | ||
| + | * unittest (moins pratique que pytest) | ||
| + | * [[https:// | ||
| + | |||
| + | Source : http:// | ||
| + | |||
| + | Voir aussi les différents types de test : | ||
| + | * Tests unitaires (au format unittest ou pytest) : units | ||
| + | * Tests d’intégration : integration | ||
| + | * Tests syntaxique : sanity | ||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | #pip3 install pytest | ||
| + | apt-get install python3-pytest | ||
| + | ~~~ | ||
| + | |||
| + | Voir aussi : Testinfra | ||
| + | |||
| + | `test_plop.py` | ||
| + | ~~~python | ||
| + | #! / | ||
| + | # coding: utf-8 | ||
| + | |||
| + | #import pytest | ||
| + | |||
| + | from func import plop | ||
| + | |||
| + | def test_plop(): | ||
| + | assert foo == bar | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | pytest-3 | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autre | ||
| + | |||
| + | `~/ | ||
| + | ~~~bash | ||
| + | #!/bin/bash | ||
| + | |||
| + | TOP_DIR=$(dirname $(realpath " | ||
| + | |||
| + | cd $TOP_DIR/ | ||
| + | nosetests --exe --with-coverage --cover-package swift --cover-erase --cover-branches --cover-html --cover-html-dir=" | ||
| + | rvalue=$? | ||
| + | rm -f .coverage | ||
| + | cd - | ||
| + | exit $rvalue | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | $ dpkg -S / | ||
| + | python-nose: | ||
| + | ~~~ | ||
| + | |||
| + | |||
