Esempio n. 1
0
def test_patterns(pattern_str, line, expected):
    pattern_re = patterns.compile_pattern(pattern_str)
    result = pattern_re.search(line)
    if result is None:
        assert expected is None, (pattern_str, line)
    else:
        result_val = result.group(0)
        assert result_val == expected, (pattern_str, line)
Esempio n. 2
0
def test_parse_versions(pattern_str, line, expected_vinfo):
    pattern_re = patterns.compile_pattern(pattern_str)
    version_match = pattern_re.search(line)

    if expected_vinfo is None:
        assert version_match is None
        return

    assert version_match is not None

    version_str = version_match.group(0)
    version_info = version.parse_version_info(version_str, pattern_str)

    assert version_info == expected_vinfo
Esempio n. 3
0
def test_curly_escapes():
    pattern = 'package_metadata = {"name": "mypackage", "version": "{pycalver}"}'
    pattern_re = patterns.compile_pattern(pattern)
    match = pattern_re.search(CURLY_BRACE_FIXTURE)
    expected = 'package_metadata = {"name": "mypackage", "version": "v201812.0123-beta"}'
    assert match.group(0) == expected
Esempio n. 4
0
def test_pattern_escapes():
    pattern = 'click.version_option(version="{pycalver}")'
    pattern_re = patterns.compile_pattern(pattern)
    match = pattern_re.search(CLI_MAIN_FIXTURE)
    expected = 'click.version_option(version="v201812.0123-beta")'
    assert match.group(0) == expected