def raises_if(test, cond, exc_class, exc_msg=None):
    try:
        yield
    except exc_class as e:
        test.assertTrue(cond)
        if exc_msg is None: pass
        elif exc_msg.startswith('...') and exc_msg != '...':
            if exc_msg.endswith('...'):
                test.assertIn(exc_msg[3:-3], str(e))
            else:
                test.assertTrue(str(e).endswith(exc_msg[3:]))
        elif exc_msg.endswith('...'):
            test.assertTrue(str(e).startswith(exc_msg[:-3]))
        else:
            test.assertEqual(str(e), exc_msg)
    else:
        test.assertFalse(cond)