Unquote the TypeError
and don't call Foo
directly, but pass the function (class Foo
) and arguments.
def test_bar_as_string(self):
self.assertRaises(TypeError, Foo, "a")
Or, you can use assertRaises
as context manager:
def test_bar_as_string(self):
with self.assertRaises(TypeError):
Foo("a")