mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
setup to reduce code duplication
This commit is contained in:
parent
e053af589e
commit
3cbf0e82b1
10 changed files with 271 additions and 267 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import pycalver.patterns as v1patterns
|
||||
from pycalver import parse
|
||||
|
||||
SETUP_PY_FIXTURE = """
|
||||
|
|
@ -11,17 +12,17 @@ setuptools.setup(
|
|||
|
||||
|
||||
def test_default_parse_patterns():
|
||||
lines = SETUP_PY_FIXTURE.splitlines()
|
||||
patterns = ["{pycalver}", "{pep440_pycalver}"]
|
||||
|
||||
matches = list(parse.iter_matches(lines, patterns))
|
||||
lines = SETUP_PY_FIXTURE.splitlines()
|
||||
patterns = ["{pycalver}", "{pep440_pycalver}"]
|
||||
re_patterns = [v1patterns.compile_pattern(p) for p in patterns]
|
||||
matches = list(parse.iter_matches(lines, re_patterns))
|
||||
assert len(matches) == 2
|
||||
|
||||
assert matches[0].lineno == 3
|
||||
assert matches[1].lineno == 6
|
||||
|
||||
assert matches[0].pattern == patterns[0]
|
||||
assert matches[1].pattern == patterns[1]
|
||||
assert matches[0].pattern == re_patterns[0]
|
||||
assert matches[1].pattern == re_patterns[1]
|
||||
|
||||
assert matches[0].match == "v201712.0002-alpha"
|
||||
assert matches[1].match == "201712.2a0"
|
||||
|
|
@ -30,16 +31,16 @@ def test_default_parse_patterns():
|
|||
def test_explicit_parse_patterns():
|
||||
lines = SETUP_PY_FIXTURE.splitlines()
|
||||
|
||||
patterns = ["__version__ = '{pycalver}'", "version='{pep440_pycalver}'"]
|
||||
|
||||
matches = list(parse.iter_matches(lines, patterns))
|
||||
patterns = ["__version__ = '{pycalver}'", "version='{pep440_pycalver}'"]
|
||||
re_patterns = [v1patterns.compile_pattern(p) for p in patterns]
|
||||
matches = list(parse.iter_matches(lines, re_patterns))
|
||||
assert len(matches) == 2
|
||||
|
||||
assert matches[0].lineno == 3
|
||||
assert matches[1].lineno == 6
|
||||
|
||||
assert matches[0].pattern == patterns[0]
|
||||
assert matches[1].pattern == patterns[1]
|
||||
assert matches[0].pattern == re_patterns[0]
|
||||
assert matches[1].pattern == re_patterns[1]
|
||||
|
||||
assert matches[0].match == "__version__ = 'v201712.0002-alpha'"
|
||||
assert matches[1].match == "version='201712.2a0'"
|
||||
|
|
@ -57,16 +58,17 @@ README_RST_FIXTURE = """
|
|||
def test_badge_parse_patterns():
|
||||
lines = README_RST_FIXTURE.splitlines()
|
||||
|
||||
patterns = ["badge/CalVer-{calver}{build}-{release}-blue.svg", ":alt: CalVer {pycalver}"]
|
||||
patterns = ["badge/CalVer-{calver}{build}-{release}-blue.svg", ":alt: CalVer {pycalver}"]
|
||||
re_patterns = [v1patterns.compile_pattern(p) for p in patterns]
|
||||
matches = list(parse.iter_matches(lines, re_patterns))
|
||||
|
||||
matches = list(parse.iter_matches(lines, patterns))
|
||||
assert len(matches) == 2
|
||||
|
||||
assert matches[0].lineno == 3
|
||||
assert matches[1].lineno == 5
|
||||
|
||||
assert matches[0].pattern == patterns[0]
|
||||
assert matches[1].pattern == patterns[1]
|
||||
assert matches[0].pattern == re_patterns[0]
|
||||
assert matches[1].pattern == re_patterns[1]
|
||||
|
||||
assert matches[0].match == "badge/CalVer-v201809.0002--beta-blue.svg"
|
||||
assert matches[1].match == ":alt: CalVer v201809.0002-beta"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue