Add documents and tests for substitution commands
This commit is contained in:
parent
3628505ea7
commit
ffa6eb7b8f
11
README.rst
11
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:
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# MIT licensed
|
||||
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, 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"
|
Loading…
Reference in New Issue