If `generate` raises a different type of error or message, then the expectation will succeed! How about just making it `cert = ca.generate(cn)`. If it raises anything, then the test will fail.