(Merge 3.3) Issue #17702: use assertRaises() for the unit test