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