def test_regex(): yes = ('"/static/foo.png"', '"/static/foo.png"', "'/static/foo.png'") no = ('"/not-static/foo.png"', '"/static/foo') # no matching quote regex = _url_replace_regex("/static/") for s in yes: print "Should match: {0!r}".format(s) assert_true(re.match(regex, s)) for s in no: print "Should not match: {0!r}".format(s) assert_false(re.match(regex, s))
def test_regex(): yes = ('"/static/foo.png"', '"/static/foo.png"', "'/static/foo.png'") no = ( '"/not-static/foo.png"', '"/static/foo', # no matching quote ) regex = _url_replace_regex('/static/') for s in yes: print 'Should match: {0!r}'.format(s) assert_true(re.match(regex, s)) for s in no: print 'Should not match: {0!r}'.format(s) assert_false(re.match(regex, s))
def test_regex(): yes = ('"/static/foo.png"', '"/static/foo.png"', "'/static/foo.png'") no = ('"/not-static/foo.png"', '"/static/foo', # no matching quote ) regex = _url_replace_regex('/static/') for s in yes: print('Should match: {0!r}'.format(s)) assert re.match(regex, s) for s in no: print('Should not match: {0!r}'.format(s)) assert not re.match(regex, s)