From f50a1a896f32cb895b15920924ede747dc5339fe Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Fri, 23 Sep 2022 15:04:16 +0200 Subject: [PATCH] Packager avant tox, car tox a vite besoin d'un paquet --- python-initiation/initiation.md | 120 ++++++++++++++++---------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/python-initiation/initiation.md b/python-initiation/initiation.md index b488628..8c35a3a 100644 --- a/python-initiation/initiation.md +++ b/python-initiation/initiation.md @@ -1341,6 +1341,51 @@ $ conda activate test ``` +# Le packaging + + +## Le packaging + +Restez dans les standards : `pyproject.toml`, `setup.cfg`. + + +## pyproject.toml et setup.cfg + +- https://github.com/JulienPalard/oeis +- https://setuptools.readthedocs.io/ + + +## pip + +```bash +(test) $ pip install . +``` + + +## pytest + +```bash +(test) $ mkdir tests/ +(test) $ pip install pytest +(test) $ editor tests/test_dice.py +``` + +Notes: C'est l'occasion de parler de assert. + + +## hypothesis + +```python +from hypothesis import given +from hypothesis.strategies import integers + +@given(integers(min_value=2, + max_value=1000)) +def test_fib(i): + assert fib(i) == fib(i-1) + fib(i-2) +``` + + # Les bonnes pratiques Notes: Prérequis: pip et venv. @@ -1451,6 +1496,21 @@ Permet de lancer les tests: Notes: c.f. gh/JulienPalard/oeis. +## pdb + +``` +breakpoint() +``` + + +## PYTHONDEVMODE=y + +Et `./configure --with-pydebug`. + +Notes: Voir mon bashrc :] Surtout "viable" depuis la 3.8. + + + # `*`, `**` @@ -1575,66 +1635,6 @@ que latin-1 et companie sont à taille fixe, et qu'UTF-8 est à taille variable. -# Le packaging - - -## Le packaging - -Restez dans les standards : `pyproject.toml`, `setup.cfg`. - - -## pyproject.toml et setup.cfg - -- https://github.com/JulienPalard/oeis -- https://setuptools.readthedocs.io/ - - -## pip - -```bash -(test) $ pip install . -``` - - -## pytest - -```bash -(test) $ mkdir tests/ -(test) $ pip install pytest -(test) $ editor tests/test_dice.py -``` - -Notes: C'est l'occasion de parler de assert. - - -## hypothesis - -```python -from hypothesis import given -from hypothesis.strategies import integers - -@given(integers(min_value=2, - max_value=1000)) -def test_fib(i): - assert fib(i) == fib(i-1) + fib(i-2) -``` - - -## pdb - -``` -breakpoint() -``` - - -## PYTHONDEVMODE=y - -Et `./configure --with-pydebug`. - -Notes: Voir mon bashrc :] Surtout "viable" depuis la 3.8. - - - # Les modules utiles - argparse