Exemple #1
0
def test_regex_return():
    regex = Regex(r"^RG(?P<the_number>\d{12})-sig\.pdf$")
    for path, valid, result in TESTDATA:
        if valid:
            dct = regex.run(path=path)
            assert dct == {"regex": {"the_number": result}}
Exemple #2
0
def test_regex_umlaut():
    regex = Regex(r"^Erträgnisaufstellung-(?P<year>\d*)\.pdf")
    doc = Path("~/Documents/Erträgnisaufstellung-1998.pdf")
    assert regex.matches(doc)
    dct = regex.run(path=doc)
    assert dct == {"regex": {"year": "1998"}}
Exemple #3
0
def test_regex_basic():
    regex = Regex(r"^RG(\d{12})-sig\.pdf$")
    for path, match, _ in TESTDATA:
        assert bool(regex.matches(path)) == match
Exemple #4
0
def test_regex_backslash():
    regex = Regex(r"^\.pdf$")
    assert regex.matches(Path(".pdf"))
    assert not regex.matches(Path("+pdf"))
    assert not regex.matches(Path("/pdf"))
    assert not regex.matches(Path("\\pdf"))
Exemple #5
0
def test_regex_return():
    regex = Regex('^RG(?P<the_number>\d{12})-sig\.pdf$')
    for path, valid, result in TESTDATA:
        if valid:
            attrs = regex.parse(path)
            assert attrs['regex'].the_number == result
Exemple #6
0
def test_regex_basic():
    regex = Regex('^RG(\d{12})-sig\.pdf$')
    for path, match, _ in TESTDATA:
        assert regex.matches(path) == match
Exemple #7
0
def test_regex_backslash():
    regex = Regex('^\.pdf$')
    assert regex.matches(Path('.pdf'))
    assert not regex.matches(Path('+pdf'))
    assert not regex.matches(Path('/pdf'))
    assert not regex.matches(Path('\pdf'))