Using assertRaises as a function instead of context manager in tests