I'm doing the Python Koans (on Python 2) and in the about_classes
part got a bit lost.
This is the code I don't know what to do / what's happening:
class Dog5(object):
def __init__(self, initial_name):
self._name = initial_name
@property
def name(self):
return self._name
def test_args_must_match_init(self):
self.assertRaises(___, self.Dog5) # Evaluates self.Dog5()
I understand why I get an error here, because the class needs an argument (and zero are given) but don't get what's the expected response here.
So lookin for a solution for this, I found this code:
def test_args_must_match_init(self):
with self.assertRaises(TypeError):
self.Dog5()
But I don't get it.
So now comes the question: What is that last piece of code doing?
What's the with assertRaises(TypeError): Dog5()
doing?