diff --git a/README.rst b/README.rst index 80b922e..47c6bbc 100644 --- a/README.rst +++ b/README.rst @@ -124,6 +124,17 @@ proxy max_concurrent Max number of concurrent jobs. Default: 20. +Global Options +-------------- +The following options applies to all checkers. + +prefix + Strip the prefix string if the version string starts with it. + +from_pattern, to_pattern + Both are Python-compatible regular expressions. If ``from_pattern`` is found + in the version string, it will be replaced with ``to_pattern`` + Search in a Webpage ------------------- Search through a specific webpage for the version string. This type of version finding has these fields: diff --git a/tests/test_substitute.py b/tests/test_substitute.py new file mode 100644 index 0000000..d1f8af7 --- /dev/null +++ b/tests/test_substitute.py @@ -0,0 +1,17 @@ +# MIT licensed +# Copyright (c) 2013-2017 lilydjwg , et al. + +import pytest +pytestmark = pytest.mark.asyncio + +async def test_substitute_prefix(get_version): + assert await get_version("example", {"manual": "v1.0", "prefix": "v"}) == "1.0" + +async def test_substitute_prefix_missing_ok(get_version): + assert await get_version("example", {"manual": "1.0", "prefix": "v"}) == "1.0" + +async def test_substitute_regex(get_version): + assert await get_version("example", {"manual": "r15c", "from_pattern": r"r(\d+)([a-z])", "to_pattern": r"r\1.\2"}) == "r15.c" + +async def test_substitute_regex_missing_ok(get_version): + assert await get_version("example", {"manual": "r15", "from_pattern": r"r(\d+)([a-z])", "to_pattern": r"r\1.\2"}) == "r15"