def test_validate(self):
        validator = Choice(['foo', 'bar', 'baz'])

        self.assertEqual('foo', validator.validate('foo'))
        self.assertEqual('bar', validator.validate('bar'))
        self.assertEqual('baz', validator.validate('baz'))

        try:
            validator.validate('foooo')
            self.fail('ValidationError not raised')
        except __HOLE__ as e:
            self.assertRegex(
                str(e),
                'Invalid value \'foooo\' \(str\): must be one of \{%s\}'
                % ', '.join(map(repr, ['foo', 'bar', 'baz']))
            )
dataset/ETHPy150Open sdispater/cleo/tests/validators/test_validators.py/ChoiceTestCase.test_validate