def test_match(): """ Given a regex object and a string that matches the regex pattern, when match() is called with the object, then it returns a function that returns the string when called with it. """ r = re.compile('^foo.*baz$') s = 'foobarbaz' validator = mod.match(r) assert validator(s) == s
def test_match(): """ Given a regex object and a string that matches the regex pattern, when match() is called with the object, then it returns a function that returns the string when called with it. """ r = re.compile("^foo.*baz$") s = "foobarbaz" validator = mod.match(r) assert validator(s) == s
def test_no_match(): """ Given a regex object and a string that does not match the regex pattern, when match() is called with the object, then it returns a function that raises ValueError exception when called with the sting. """ r = re.compile('^foo.*baz$') s = 'foobarbazooka' validator = mod.match(r) with pytest.raises(ValueError): validator(s)
def test_no_match(): """ Given a regex object and a string that does not match the regex pattern, when match() is called with the object, then it returns a function that raises ValueError exception when called with the sting. """ r = re.compile("^foo.*baz$") s = "foobarbazooka" validator = mod.match(r) with pytest.raises(ValueError): validator(s)