':py:meth:`PKeyType.generate_key` takes two arguments, the first giving the key
type as one of :py:data:`TYPE_RSA` or :py:data:`TYPE_DSA` and the second giving the
number of bits to generate.  If an invalid type is specified or
generation fails, :py:exc:`Error` is raised.  If an invalid number of bits is
specified, :py:exc:`ValueError` or :py:exc:`Error` is raised.'

def test_failedGeneration(self):

    key = PKey()
    self.assertRaises(TypeError, key.generate_key)
    self.assertRaises(TypeError, key.generate_key, 1, 2, 3)
    self.assertRaises(TypeError, key.generate_key, 'foo', 'bar')
    self.assertRaises(Error, key.generate_key, (-1), 0)
    self.assertRaises(ValueError, key.generate_key, TYPE_RSA, (-1))
    self.assertRaises(ValueError, key.generate_key, TYPE_RSA, 0)
