Created
March 3, 2014 20:15
-
-
Save Grahack/9333665 to your computer and use it in GitHub Desktop.
Testing obiwan, I don't understand why some exceptions are not raised.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Testing the obiwan module. | |
https://github.com/williame/obiwan | |
""" | |
from obiwan import * | |
install_obiwan_runtime_check() | |
def id1(x: int) -> int: | |
"""Identitée | |
>>> id1(2) | |
Traceback (most recent call last): | |
... | |
obiwan.ObiwanError: id1()-> is <class 'NoneType'> but should be <class 'int'> | |
""" | |
return | |
def id2(x: int) -> int: | |
"""Identitée | |
>>> id2(2) | |
2 | |
>>> id2(2.0) | |
Traceback (most recent call last): | |
... | |
obiwan.ObiwanError: id(x) is <class 'float'> but should be <class 'int'> | |
""" | |
return x | |
def somme1(a: int, b: int) -> int: | |
"""Somme | |
>>> somme1(2, 2) | |
4 | |
>>> somme1(2, 2.0) | |
Traceback (most recent call last): | |
... | |
obiwan.ObiwanError: somme1(b) is <class 'float'> but should be <class 'int'> | |
""" | |
return a + b | |
def somme2(a: int, b: float) -> number: | |
"""Somme | |
>>> somme2(2, 2) | |
Traceback (most recent call last): | |
... | |
obiwan.ObiwanError: somme2(b) is <class 'int'> but should be <class 'float'> | |
""" | |
return a + b | |
import doctest | |
doctest.testmod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment