Created
May 1, 2017 12:45
-
-
Save vinniec/9b8af159489f5de745ad27df35017970 to your computer and use it in GitHub Desktop.
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
In [12]: class Giocatore(): | |
...: """ | |
...: Questa classe rappresenta un giocatore | |
...: | |
...: Età non valida: ValueError | |
...: >>> try: | |
...: >>> g = Giocatore('rinco', 'asda') | |
...: >>> except ValueError: | |
...: >>> print('ValueError') | |
...: ValueError | |
...: """ | |
...: def __init__(self, nome, eta=None): | |
...: self.nome = nome | |
...: if eta is None: self.eta = random.randint(0,100) #età casuale | |
...: else: self.eta = int(eta) | |
...: | |
In [13]: doctest.testmod() | |
********************************************************************** | |
File "__main__", line ?, in __main__.Giocatore | |
Failed example: | |
try: | |
Exception raised: | |
Traceback (most recent call last): | |
File "/home/vinnie/anaconda3/lib/python3.6/doctest.py", line 1330, in __run | |
compileflags, 1), test.globs) | |
File "<doctest __main__.Giocatore[0]>", line 1 | |
try: | |
^ | |
SyntaxError: unexpected EOF while parsing | |
********************************************************************** | |
File "__main__", line ?, in __main__.Giocatore | |
Failed example: | |
g = Giocatore('rinco', 'asda') | |
Exception raised: | |
Traceback (most recent call last): | |
File "/home/vinnie/anaconda3/lib/python3.6/doctest.py", line 1330, in __run | |
compileflags, 1), test.globs) | |
File "<doctest __main__.Giocatore[1]>", line 1 | |
g = Giocatore('rinco', 'asda') | |
^ | |
IndentationError: unexpected indent | |
********************************************************************** | |
File "__main__", line ?, in __main__.Giocatore | |
Failed example: | |
except ValueError: | |
Exception raised: | |
Traceback (most recent call last): | |
File "/home/vinnie/anaconda3/lib/python3.6/doctest.py", line 1330, in __run | |
compileflags, 1), test.globs) | |
File "<doctest __main__.Giocatore[2]>", line 1 | |
except ValueError: | |
^ | |
SyntaxError: invalid syntax | |
********************************************************************** | |
File "__main__", line ?, in __main__.Giocatore | |
Failed example: | |
print('ValueError') | |
Exception raised: | |
Traceback (most recent call last): | |
File "/home/vinnie/anaconda3/lib/python3.6/doctest.py", line 1330, in __run | |
compileflags, 1), test.globs) | |
File "<doctest __main__.Giocatore[3]>", line 1 | |
print('ValueError') | |
^ | |
IndentationError: unexpected indent | |
********************************************************************** | |
1 items had failures: | |
4 of 4 in __main__.Giocatore | |
***Test Failed*** 4 failures. | |
Out[13]: TestResults(failed=4, attempted=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment