From a62dc1aaa4a1240a100663f962fa7f450562d2ae Mon Sep 17 00:00:00 2001 From: freezed <2160318-free_zed@users.noreply.gitlab.com> Date: Thu, 15 Apr 2021 00:15:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20first=20doctests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit relate to forga/process/fr/embarquement#6 --- tuto-pysdur/pgcd.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tuto-pysdur/pgcd.py b/tuto-pysdur/pgcd.py index 75b9864..80bc786 100644 --- a/tuto-pysdur/pgcd.py +++ b/tuto-pysdur/pgcd.py @@ -10,6 +10,10 @@ This is a script following https://gitlab.com/forga/process/fr/embarquement/-/issues/6 The goal is to build durable python script using standard library + +:Tests: +>>> pgcd(561, 357) +51 """ @@ -17,6 +21,16 @@ def pgcd(a,b): """ This function find the Greatest Common Divisor (PGCD in French) between a & b + + :Tests: + >>> pgcd(561, 357) + 51 + >>> pgcd(63, 42) + 21 + >>> pgcd(21, 15) + 3 + >>> pgcd(910, 42) + 14 """ rest = a - b check = b - rest @@ -31,4 +45,5 @@ def pgcd(a,b): if __name__ == '__main__': - pgcd(561, 357) + import doctest + doctest.testmod()