mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 06:20:08 +01:00
parent
809a6becb6
commit
5bf12a49ce
3 changed files with 90 additions and 68 deletions
|
|
@ -87,6 +87,7 @@ COMPOSITE_PART_PATTERNS = {
|
|||
PART_PATTERNS = {
|
||||
'year' : r"\d{4}",
|
||||
'month' : r"(?:0[0-9]|1[0-2])",
|
||||
'month_short': r"(?:1[0-2]|[1-9])",
|
||||
'build_no' : r"\d{4,}",
|
||||
'pep440_tag' : r"(?:a|b|dev|rc|post)?\d*",
|
||||
'tag' : r"(?:alpha|beta|dev|rc|post|final)",
|
||||
|
|
@ -130,6 +131,7 @@ FULL_PART_FORMATS = {
|
|||
# is treates specially in version.format
|
||||
# 'release' : "-{tag}",
|
||||
'month' : "{month:02}",
|
||||
'month_short': "{month}",
|
||||
'build_no' : "{bid}",
|
||||
'iso_week' : "{iso_week:02}",
|
||||
'us_week' : "{us_week:02}",
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ TODAY = dt.datetime.utcnow().date()
|
|||
PATTERN_PART_FIELDS = {
|
||||
'year' : 'year',
|
||||
'month' : 'month',
|
||||
'month_short': 'month',
|
||||
'pep440_tag' : 'tag',
|
||||
'tag' : 'tag',
|
||||
'yy' : 'year',
|
||||
|
|
|
|||
|
|
@ -53,6 +53,25 @@ def test_re_pattern_parts(part_name, line, expected):
|
|||
assert result_val == expected, (part_name, line)
|
||||
|
||||
|
||||
PATTERN_CASES = [
|
||||
(r"v{year}.{month}.{MINOR}" , "v2017.11.1" , "v2017.11.1"),
|
||||
(r"v{year}.{month}.{MINOR}" , "v2017.07.12", "v2017.07.12"),
|
||||
(r"v{year}.{month_short}.{MINOR}", "v2017.11.1" , "v2017.11.1"),
|
||||
(r"v{year}.{month_short}.{MINOR}", "v2017.7.12" , "v2017.7.12"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pattern_str, line, expected", PATTERN_CASES)
|
||||
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)
|
||||
|
||||
|
||||
CLI_MAIN_FIXTURE = """
|
||||
@click.group()
|
||||
@click.version_option(version="v201812.0123-beta")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue