Adapt assertRaises context manager to Python 2.6 code for more readable tests.
Change assertRaises tests to use context manager ("with") syntax.