示例#1
0
 def test_schema(self):
     assert inputs.regex(r'^[0-9]+$').__schema__ == {
         'type': 'string',
         'pattern': '^[0-9]+$'
     }
示例#2
0
 def test_bad_input(self, value):
     num_only = inputs.regex(r'^[0-9]+$')
     with pytest.raises(ValueError):
         num_only(value)
示例#3
0
 def test_bad_pattern(self):
     with pytest.raises(re.error):
         inputs.regex('[')
示例#4
0
 def test_valid_input(self, value):
     num_only = inputs.regex(r'^[0-9]+$')
     assert num_only(value) == value