Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
d4d595ed68
|
|||
9026dd56cc
|
|||
6bd2b3c66c
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
|
*.pyc
|
||||||
|
|
||||||
venv
|
venv
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
stages:
|
stages:
|
||||||
- linting
|
- linting
|
||||||
|
- test
|
||||||
|
|
||||||
|
|
||||||
flake8:
|
flake8:
|
||||||
@ -18,3 +19,9 @@ pylint:
|
|||||||
- pip install pylint --no-cache-dir
|
- pip install pylint --no-cache-dir
|
||||||
script: pylint main.py
|
script: pylint main.py
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
image: python:3-alpine
|
||||||
|
script: pytest --show-locals .
|
||||||
|
8
main.py
Normal file → Executable file
8
main.py
Normal file → Executable 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
|
Ce script est utilisé en guise d'appui pour le séminaire Crans d'introduction
|
||||||
@ -24,7 +24,11 @@ def main():
|
|||||||
while True:
|
while True:
|
||||||
command = input("> ")
|
command = input("> ")
|
||||||
args = command.split(" ")
|
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():
|
def aide():
|
||||||
|
24
main_test.py
Executable file
24
main_test.py
Executable 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")
|
Reference in New Issue
Block a user