3 Commits
v5 ... v7

Author SHA1 Message Date
d4d595ed68 Ajout d'un fichier de test avec pytest
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-01-26 17:07:12 +01:00
9026dd56cc Changement dans l'exécution du script
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-01-26 16:52:15 +01:00
6bd2b3c66c On exécute le programme
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-01-26 16:50:52 +01:00
4 changed files with 39 additions and 2 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
*.pyc
venv

View File

@ -1,5 +1,6 @@
stages:
- linting
- test
flake8:
@ -18,3 +19,9 @@ pylint:
- pip install pylint --no-cache-dir
script: pylint main.py
allow_failure: true
test:
stage: test
image: python:3-alpine
script: pytest --show-locals .

8
main.py Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Ce script est utilisé en guise d'appui pour le séminaire Crans d'introduction
@ -24,7 +24,11 @@ def main():
while True:
command = input("> ")
args = command.split(" ")
print(globals()[args[0]](*args[1:]))
print(commande(args[0], *args[1:]))
def commande(name: str, *args):
return globals()[name](*args)
def aide():

24
main_test.py Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
"""
Exécution des tests du script.
"""
import unittest
import main
def test_aide():
"""
On essaie d'afficher l'aide, et on vérifie si ça affiche la bonne chose.
"""
res = main.commande("aide")
lines = res.split("\n")
assert len(lines) == 6
assert lines[0].startswith("aide")
assert lines[1].startswith("seminaire")
assert lines[2].startswith("blague")
assert lines[3].startswith("calcul")
assert lines[4].startswith("tri")
assert lines[5].startswith("stop")