# coding: utf-8
# https://stackoverflow.com/questions/129507/how-do-you-test-that-a-python-function-throws-an-exception
import unittest
def test(a):
assert a >=0
class A(unittest.TestCase):
def test_one(self):
with self.assertRaises(AssertionError) as context:
test(-5)
# print context
self.assertTrue(isinstance(context.exception, AssertionError))
print('erfolg')
a = A()
a.test_one()