Skip to content

Instantly share code, notes, and snippets.

@vinniec
Created May 1, 2017 12:45
Show Gist options
  • Save vinniec/9b8af159489f5de745ad27df35017970 to your computer and use it in GitHub Desktop.
Save vinniec/9b8af159489f5de745ad27df35017970 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
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