示例#1
0
def test_wildcard_partial():
    m = dotted.match('*', 'abc.def')
    assert m == 'abc.def'

    m = dotted.match('*.*', 'abc.def')
    assert m == 'abc.def'

    m = dotted.match('*.*.*', 'abc.def')
    assert m is None
示例#2
0
def test_wilcard_full():
    m = dotted.match('*', 'abc.def', partial=False)
    assert m is None

    m = dotted.match('*.*', 'abc.def', partial=False)
    assert m == 'abc.def'

    m = dotted.match('*.*.*', 'abc.def', partial=False)
    assert m is None
示例#3
0
def test_invert_match_const():
    r = dotted.match('-hello', '-hello')
    assert r == '-hello'

    r = dotted.match('-hello', 'hello')
    assert not r

    r = dotted.match('hello', '-hello')
    assert not r
示例#4
0
def test_slice_match():
    m = dotted.match('hello[]', 'hello[]')
    assert m == 'hello[]'

    m = dotted.match('hello[:2]', 'hello[]')
    assert m is None

    m = dotted.match('hello[]', 'hello[:2]')
    assert m == 'hello[:2]'
示例#5
0
def test_appender_match():
    r = dotted.match('[*]', '[+]')
    assert r == '[+]'

    r = dotted.match('[+]', '[+?]')
    assert r == '[+?]'

    r = dotted.match('[+?]', '[+]')
    assert r is None
示例#6
0
def test_wilcard_groups():
    m, g = dotted.match('*', 'abc.def', groups=True)
    assert m == 'abc.def'
    assert g == ('abc.def', )

    m, g = dotted.match('*.*', 'abc.def', groups=True)
    assert m == 'abc.def'
    assert g == ('abc', 'def')

    m, g = dotted.match('*.*.*', 'abc.def', groups=True)
    assert m is None
    assert g == ()
示例#7
0
def test_pattern_to_pattern():
    assert dotted.match('*', '*') == '*'
    assert dotted.match('*', '*.*') == '*.*'
    assert dotted.match('*.*', '*') is None
    assert dotted.match('*', '*?') == '*?'
    assert dotted.match('*?', '*') is None
    assert dotted.match('*', '/hello/') == '/hello/'
    assert dotted.match('*', '/hello/?') == '/hello/?'

    assert dotted.match('/.*/', '/hello/') == '/hello/'
    assert dotted.match('/.*/', '/hello/?') == '/hello/?'
    assert dotted.match('/.*/?', '/hello/') is None
    assert dotted.match('/.*/?', '/hello/?') == '/hello/?'

    assert dotted.match('*', '-*') is None
    assert dotted.match('-*', '*') is None
    assert dotted.match('-*', '-*') == '-*'
示例#8
0
def test_non_numeric_match():
    m = dotted.match('*', 'street1')
    assert m == 'street1'

    m = dotted.match('*', '0hello')
    assert m == '0hello'
示例#9
0
def test_regex():
    m = dotted.match('/a.+/', 'abc.def')
    assert m == 'abc.def'

    m = dotted.match('/a.+/', 'abc.def', partial=False)
    assert m is None
示例#10
0
def test_invert_match_pattern():
    r = dotted.match('-*', '-hello')
    assert r == '-hello'

    r = dotted.match('*', '-hello')
    assert not r