Пример #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