def test_unknown(self): field = 'ABC' with self.assertRaisesRegex(ValueError, '^Unknown x509 name field: ABC$') as e: parse_name('/%s=example.com' % field) self.assertEqual(e.exception.args, ('Unknown x509 name field: %s' % field, ))
def __call__(self, parser, namespace, value, option_string=None): try: value = parse_name(value) except ValueError as e: parser.error(e) setattr(namespace, self.dest, value)
def assertSubject(self, actual, expected): self.assertEqual(list(parse_name(actual).items()), expected)