Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
60e09751da
|
|||
1fc558a2ad
|
|||
df223bd19e
|
@ -25,5 +25,5 @@ test:
|
||||
stage: test
|
||||
image: python:3-alpine
|
||||
before_script:
|
||||
- pip install pytest --no-cache-dir
|
||||
script: pytest --showlocals .
|
||||
- pip install pytest pytest-cov --no-cache-dir
|
||||
script: pytest --showlocals --cov=main --cov=main_test --cov-report=term-missing .
|
||||
|
14
main.py
14
main.py
@ -38,13 +38,13 @@ def aide():
|
||||
"""
|
||||
Affiche l'aide
|
||||
"""
|
||||
print("aide\t\tAffiche l'aide")
|
||||
print("seminaire\tLance le séminaire")
|
||||
print("blague\t\tRaconte une blague")
|
||||
print("calcul\t\tVérifie une opération arithmétique. "
|
||||
"Par exemple, check(1, 2, 3, '+') renvoie True")
|
||||
print("tri\t\tTrie une liste d'entiers.")
|
||||
print("stop\t\tQuitte le programme")
|
||||
return "aide\t\tAffiche l'aide\n" \
|
||||
"seminaire\tLance le séminaire\n" \
|
||||
"blague\t\tRaconte une blague\n" \
|
||||
"calcul\t\tVérifie une opération arithmétique. " \
|
||||
"Par exemple, check(1, 2, 3, '+') renvoie True\n" \
|
||||
"tri\t\tTrie une liste d'entiers.\n" \
|
||||
"stop\t\tQuitte le programme"
|
||||
|
||||
|
||||
def seminaire():
|
||||
|
29
main_test.py
29
main_test.py
@ -4,19 +4,26 @@
|
||||
Exécution des tests du script.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import main
|
||||
|
||||
|
||||
def test_aide():
|
||||
class TestMain(unittest.TestCase):
|
||||
"""
|
||||
On essaie d'afficher l'aide, et on vérifie si ça affiche la bonne chose.
|
||||
Cette classe permet d'executer l'ensemble des scripts
|
||||
"""
|
||||
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")
|
||||
|
||||
def test_aide(self):
|
||||
"""
|
||||
On essaie d'afficher l'aide, et on vérifie si ça affiche la bonne chose.
|
||||
"""
|
||||
res = main.commande("aide")
|
||||
lines = res.split("\n")
|
||||
self.assertEqual(len(lines), 6)
|
||||
self.assertTrue(lines[0].startswith("aide"))
|
||||
self.assertTrue(lines[1].startswith("seminaire"))
|
||||
self.assertTrue(lines[2].startswith("blague"))
|
||||
self.assertTrue(lines[3].startswith("calcul"))
|
||||
self.assertTrue(lines[4].startswith("tri"))
|
||||
self.assertTrue(lines[5].startswith("stop"))
|
||||
|
Reference in New Issue
Block a user