Select Git revision
test_analyse_simple.py
-
Romain Vuillemot authoredRomain Vuillemot authored
exceptions.py 772 B
# https://docs.python.org/3/tutorial/errors.html
import addition
class Error(Exception):
"""Classe de base d'exceptions"""
pass
class ValueTooSmallError(Error):
"""Si la valeur est trop petite"""
pass
if __name__ == "__main__":
a, b = 1, 2
try:
if a < 0 or b < 0:
raise ValueTooSmallError
# assert addition(a, b) == 3
# assert not addition(a, b) == 4
# addition(a, "c")
# raise EnvironmentError
except AssertionError:
print("test non validé")
except TypeError:
print("problème de typage")
except ValueTooSmallError:
print("valeur trop petite")
except:
print("erreur inconnue")
finally:
print("c'est la fin, toujours exécuté")