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