Outils pour utilisateurs

Outils du site


tech:python_tests_unitaires

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
tech:python_tests_unitaires [2026/02/07 10:46] Jean-Baptistetech:python_tests_unitaires [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon Code Python Unittest}}
 +
 +# Python tests unitaires
 +
 +Voir aussi:
 +* unittest (moins pratique que pytest)
 +* [[https://medium.com/python-in-plain-english/unit-testing-in-python-tox-and-nox-833e4bbce729]]
 +
 +Source : http://sametmax.com/un-gros-guide-bien-gras-sur-les-tests-unitaires-en-python-partie-3/
 +
 +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
 +#! /usr/bin/python3
 +# coding: utf-8
 +
 +#import pytest
 +
 +from func import plop
 +
 +def test_plop():
 +    assert foo == bar
 +~~~
 +
 +~~~bash
 +pytest-3
 +~~~
 +
 +
 +## Autre
 +
 +`~/swift/.unittests`
 +~~~bash
 +#!/bin/bash
 +
 +TOP_DIR=$(dirname $(realpath "$0"))
 +
 +cd $TOP_DIR/test/unit
 +nosetests --exe --with-coverage --cover-package swift --cover-erase --cover-branches --cover-html --cover-html-dir="$TOP_DIR"/cover $@
 +rvalue=$?
 +rm -f .coverage
 +cd -
 +exit $rvalue
 +~~~
 +
 +~~~
 +$ dpkg -S /usr/bin/nosetests
 +python-nose: /usr/bin/nosetests
 +~~~
 +
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki