예제 #1
0
    def __init__(self,
                 question,
                 value,
                 validator=None,
                 multiple=False,
                 printable_name=None):
        """ Basic Question class.

            Supports simple question and answer or question and multiple
            answers (note: list/hash validators have caveats).  Also
            support for one or more Validator classes to ensure the answer
            given meets the question criteria.
        """
        self.question = question
        self.value = value
        self.multiple = multiple
        if printable_name:
            self.printable_name = printable_name
        else:
            self.printable_name = value
        if validator is None:
            self.validator = Validator()
        else:
            self.validator = validator
        self._questions = []
예제 #2
0
 def test_error(self):
     v = Validator()
     v.validate('')
     assert v.error() == 'ERROR: Can not be empty.  Please provide a value.'
예제 #3
0
 def test_blank(self):
     v = Validator(blank=True)
     assert v.validate('') is True
     assert v.choice() == ''
예제 #4
0
 def test_validate(self):
     v = Validator()
     assert v.validate('') is False
     assert v.error_message is not None