mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 22:40:09 +01:00
update defaults and tests
This commit is contained in:
parent
5f66a42c17
commit
a3499c19a6
17 changed files with 400 additions and 306 deletions
2
test/fixtures/project_a/README.md
vendored
2
test/fixtures/project_a/README.md
vendored
|
|
@ -1,3 +1,3 @@
|
|||
# PyCalVer README Fixture
|
||||
# Python CalVer README Fixture
|
||||
|
||||
Current Version: v2016.0123-alpha
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
[pycalver]
|
||||
[calver]
|
||||
current_version = "v2017.0123-alpha"
|
||||
version_pattern = "vYYYY.BUILD[-TAG]"
|
||||
commit = true
|
||||
tag = true
|
||||
push = true
|
||||
|
||||
[pycalver.file_patterns]
|
||||
"pycalver.toml" = [
|
||||
[calver.file_patterns]
|
||||
"calver.toml" = [
|
||||
'current_version = "{version}"',
|
||||
]
|
||||
|
||||
4
test/fixtures/project_b/setup.cfg
vendored
4
test/fixtures/project_b/setup.cfg
vendored
|
|
@ -1,11 +1,11 @@
|
|||
[pycalver]
|
||||
[calver]
|
||||
current_version = v201307.0456-beta
|
||||
version_pattern = {pycalver}
|
||||
commit = True
|
||||
tag = True
|
||||
push = True
|
||||
|
||||
[pycalver:file_patterns]
|
||||
[calver:file_patterns]
|
||||
setup.cfg =
|
||||
current_version = {version}
|
||||
setup.py =
|
||||
|
|
|
|||
7
test/fixtures/project_b/setup.py
vendored
7
test/fixtures/project_b/setup.py
vendored
|
|
@ -1,3 +1,8 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(name="mylib", license="MIT", version="201307.456b0", keywords="awesome library")
|
||||
setuptools.setup(
|
||||
name="mylib",
|
||||
license="MIT",
|
||||
version="201307.456b0",
|
||||
keywords="awesome library",
|
||||
)
|
||||
|
|
|
|||
2
test/fixtures/project_c/pyproject.toml
vendored
2
test/fixtures/project_c/pyproject.toml
vendored
|
|
@ -1,4 +1,4 @@
|
|||
[pycalver]
|
||||
[calver]
|
||||
current_version = "v2017q1.54321"
|
||||
version_pattern = "v{year}q{quarter}.{build_no}"
|
||||
commit = true
|
||||
|
|
|
|||
2
test/fixtures/project_d/pyproject.toml
vendored
2
test/fixtures/project_d/pyproject.toml
vendored
|
|
@ -1,4 +1,4 @@
|
|||
[pycalver]
|
||||
[calver]
|
||||
current_version = "v2017q1.54321"
|
||||
version_pattern = "vYYYYqQ.BUILD"
|
||||
commit = true
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ license_file = LICENSE
|
|||
universal = 1
|
||||
"""
|
||||
|
||||
PYCALVER_TOML_FIXTURE = """
|
||||
CALVER_TOML_FIXTURE = """
|
||||
"""
|
||||
|
||||
PYPROJECT_TOML_FIXTURE = """
|
||||
|
|
@ -51,11 +51,11 @@ requires = ["setuptools", "wheel"]
|
|||
"""
|
||||
|
||||
ENV = {
|
||||
'GIT_AUTHOR_NAME' : "pycalver_tester",
|
||||
'GIT_COMMITTER_NAME' : "pycalver_tester",
|
||||
'GIT_AUTHOR_EMAIL' : "pycalver_tester@nowhere.com",
|
||||
'GIT_COMMITTER_EMAIL': "pycalver_tester@nowhere.com",
|
||||
'HGUSER' : "pycalver_tester",
|
||||
'GIT_AUTHOR_NAME' : "calver_tester",
|
||||
'GIT_COMMITTER_NAME' : "calver_tester",
|
||||
'GIT_AUTHOR_EMAIL' : "calver_tester@nowhere.com",
|
||||
'GIT_COMMITTER_EMAIL': "calver_tester@nowhere.com",
|
||||
'HGUSER' : "calver_tester",
|
||||
'PATH' : os.environ['PATH'],
|
||||
}
|
||||
|
||||
|
|
@ -64,11 +64,11 @@ def shell(*cmd):
|
|||
return sp.check_output(cmd, env=ENV)
|
||||
|
||||
|
||||
DEBUG_LOG = 0
|
||||
ECHO_CAPLOG = os.getenv('ECHO_CAPLOG') == "1"
|
||||
|
||||
|
||||
def _debug_records(caplog):
|
||||
if DEBUG_LOG:
|
||||
if ECHO_CAPLOG:
|
||||
print()
|
||||
for record in caplog.records:
|
||||
print(record)
|
||||
|
|
@ -233,7 +233,11 @@ def _add_project_files(*files):
|
|||
|
||||
if "pycalver.toml" in files:
|
||||
with pl.Path("pycalver.toml").open(mode="wt", encoding="utf-8") as fobj:
|
||||
fobj.write(PYCALVER_TOML_FIXTURE)
|
||||
fobj.write(CALVER_TOML_FIXTURE)
|
||||
|
||||
if "calver.toml" in files:
|
||||
with pl.Path("calver.toml").open(mode="wt", encoding="utf-8") as fobj:
|
||||
fobj.write(CALVER_TOML_FIXTURE)
|
||||
|
||||
if "pyproject.toml" in files:
|
||||
with pl.Path("pyproject.toml").open(mode="wt", encoding="utf-8") as fobj:
|
||||
|
|
@ -269,14 +273,14 @@ def test_novcs_nocfg_init(runner, caplog):
|
|||
# dry mode test
|
||||
result = runner.invoke(cli.cli, ['init', "-vv", "--dry"])
|
||||
assert result.exit_code == 0
|
||||
assert not os.path.exists("pycalver.toml")
|
||||
assert not os.path.exists("calver.toml")
|
||||
|
||||
# non dry mode
|
||||
result = runner.invoke(cli.cli, ['init', "-vv"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert os.path.exists("pycalver.toml")
|
||||
with pl.Path("pycalver.toml").open(mode="r", encoding="utf-8") as fobj:
|
||||
assert os.path.exists("calver.toml")
|
||||
with pl.Path("calver.toml").open(mode="r", encoding="utf-8") as fobj:
|
||||
cfg_content = fobj.read()
|
||||
|
||||
base_str = config.DEFAULT_TOML_BASE_TMPL.format(initial_version=config._initial_version())
|
||||
|
|
@ -318,9 +322,10 @@ def test_novcs_setupcfg_init(runner):
|
|||
assert f"PEP440 : {config._initial_version_pep440()}\n" in result.output
|
||||
|
||||
|
||||
def test_novcs_pyproject_init(runner):
|
||||
def test_novcs_pyproject_init(runner, caplog):
|
||||
_add_project_files("README.md", "pyproject.toml")
|
||||
result = runner.invoke(cli.cli, ['init', "-vv"])
|
||||
_debug_records(caplog)
|
||||
assert result.exit_code == 0
|
||||
|
||||
with pl.Path("pyproject.toml").open(mode="r", encoding="utf-8") as fobj:
|
||||
|
|
@ -368,7 +373,7 @@ def test_git_init(runner, version_pattern, cur_version, cur_pep440):
|
|||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val(
|
||||
"pycalver.toml",
|
||||
"calver.toml",
|
||||
version_pattern=version_pattern,
|
||||
current_version='"' + cur_version + '"',
|
||||
)
|
||||
|
|
@ -387,7 +392,7 @@ def test_hg_init(runner, version_pattern, cur_version, cur_pep440):
|
|||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val(
|
||||
"pycalver.toml",
|
||||
"calver.toml",
|
||||
version_pattern=version_pattern,
|
||||
current_version='"' + cur_version + '"',
|
||||
)
|
||||
|
|
@ -408,7 +413,7 @@ def test_v1_git_tag_eval(runner, version_pattern, cur_version, cur_pep440):
|
|||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val(
|
||||
"pycalver.toml",
|
||||
"calver.toml",
|
||||
version_pattern=version_pattern,
|
||||
current_version='"' + cur_version + '"',
|
||||
)
|
||||
|
|
@ -434,7 +439,7 @@ def test_hg_tag_eval(runner, version_pattern, cur_version, cur_pep440):
|
|||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val(
|
||||
"pycalver.toml",
|
||||
"calver.toml",
|
||||
version_pattern=version_pattern,
|
||||
current_version='"' + cur_version + '"',
|
||||
)
|
||||
|
|
@ -458,7 +463,7 @@ def test_novcs_bump(runner, version_pattern, cur_version, cur_pep440):
|
|||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val(
|
||||
"pycalver.toml",
|
||||
"calver.toml",
|
||||
version_pattern=version_pattern,
|
||||
current_version='"' + cur_version + '"',
|
||||
)
|
||||
|
|
@ -494,12 +499,12 @@ def test_git_bump(runner, caplog, version_pattern, cur_version, cur_pep440):
|
|||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val(
|
||||
"pycalver.toml",
|
||||
"calver.toml",
|
||||
version_pattern=version_pattern,
|
||||
current_version='"' + cur_version + '"',
|
||||
)
|
||||
|
||||
shell("git", "add", "pycalver.toml")
|
||||
shell("git", "add", "calver.toml")
|
||||
shell("git", "commit", "-m", "initial commit")
|
||||
|
||||
result = runner.invoke(cli.cli, ['bump', "-vv"])
|
||||
|
|
@ -522,12 +527,12 @@ def test_hg_bump(runner, version_pattern, cur_version, cur_pep440):
|
|||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val(
|
||||
"pycalver.toml",
|
||||
"calver.toml",
|
||||
version_pattern=version_pattern,
|
||||
current_version='"' + cur_version + '"',
|
||||
)
|
||||
|
||||
shell("hg", "add", "pycalver.toml")
|
||||
shell("hg", "add", "calver.toml")
|
||||
shell("hg", "commit", "-m", "initial commit")
|
||||
|
||||
result = runner.invoke(cli.cli, ['bump', "-vv"])
|
||||
|
|
@ -551,9 +556,9 @@ def test_empty_git_bump(runner, caplog):
|
|||
with pl.Path("setup.cfg").open(mode="r") as fobj:
|
||||
default_cfg_data = fobj.read()
|
||||
|
||||
assert "[pycalver]\n" in default_cfg_data
|
||||
assert "[calver]\n" in default_cfg_data
|
||||
assert "\ncurrent_version = " in default_cfg_data
|
||||
assert "\n[pycalver:file_patterns]\n" in default_cfg_data
|
||||
assert "\n[calver:file_patterns]\n" in default_cfg_data
|
||||
assert "\nsetup.cfg =\n" in default_cfg_data
|
||||
|
||||
result = runner.invoke(cli.cli, ['bump'])
|
||||
|
|
@ -573,9 +578,9 @@ def test_empty_hg_bump(runner, caplog):
|
|||
with pl.Path("setup.cfg").open(mode="r") as fobj:
|
||||
default_cfg_text = fobj.read()
|
||||
|
||||
assert "[pycalver]\n" in default_cfg_text
|
||||
assert "[calver]\n" in default_cfg_text
|
||||
assert "\ncurrent_version = " in default_cfg_text
|
||||
assert "\n[pycalver:file_patterns]\n" in default_cfg_text
|
||||
assert "\n[calver:file_patterns]\n" in default_cfg_text
|
||||
assert "\nsetup.cfg =\n" in default_cfg_text
|
||||
|
||||
result = runner.invoke(cli.cli, ['bump'])
|
||||
|
|
@ -899,11 +904,11 @@ def test_get_latest_vcs_version_tag(runner):
|
|||
result = runner.invoke(cli.cli, ['init', "-vv"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
_update_config_val("pycalver.toml", push="false")
|
||||
_update_config_val("pycalver.toml", current_version='"0.1.8"')
|
||||
_update_config_val("pycalver.toml", version_pattern='"MAJOR.MINOR.PATCH"')
|
||||
_update_config_val("calver.toml", push="false")
|
||||
_update_config_val("calver.toml", current_version='"0.1.8"')
|
||||
_update_config_val("calver.toml", version_pattern='"MAJOR.MINOR.PATCH"')
|
||||
|
||||
_vcs_init("git", files=["pycalver.toml"])
|
||||
_vcs_init("git", files=["calver.toml"])
|
||||
|
||||
result = runner.invoke(cli.cli, ['bump', "--patch"])
|
||||
assert result.exit_code == 0
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ from pycalver2 import config
|
|||
|
||||
PYCALVER_TOML_FIXTURE_1 = """
|
||||
[pycalver]
|
||||
current_version = "v201808.0123-alpha"
|
||||
current_version = "v2020.1003-alpha"
|
||||
version_pattern = "vYYYY.BUILD[-TAG]"
|
||||
commit = true
|
||||
tag = true
|
||||
push = true
|
||||
|
|
@ -35,6 +36,9 @@ PYCALVER_TOML_FIXTURE_2 = """
|
|||
[pycalver]
|
||||
current_version = "1.2.3"
|
||||
version_pattern = "{semver}"
|
||||
commit = false
|
||||
tag = false
|
||||
push = false
|
||||
|
||||
[pycalver.file_patterns]
|
||||
"README.md" = [
|
||||
|
|
@ -46,15 +50,34 @@ version_pattern = "{semver}"
|
|||
]
|
||||
"""
|
||||
|
||||
CALVER_TOML_FIXTURE_3 = """
|
||||
[calver]
|
||||
current_version = "v201808.0123-alpha"
|
||||
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||
commit = true
|
||||
tag = true
|
||||
push = true
|
||||
|
||||
[calver.file_patterns]
|
||||
"README.md" = [
|
||||
"{version}",
|
||||
"{pep440_version}",
|
||||
]
|
||||
"calver.toml" = [
|
||||
'current_version = "{version}"',
|
||||
]
|
||||
"""
|
||||
|
||||
|
||||
SETUP_CFG_FIXTURE = """
|
||||
[pycalver]
|
||||
[calver]
|
||||
current_version = "v201808.0456-beta"
|
||||
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||
commit = True
|
||||
tag = True
|
||||
push = True
|
||||
|
||||
[pycalver:file_patterns]
|
||||
[calver:file_patterns]
|
||||
setup.py =
|
||||
{version}
|
||||
{pep440_version}
|
||||
|
|
@ -64,7 +87,7 @@ setup.cfg =
|
|||
|
||||
|
||||
NEW_PATTERN_CFG_FIXTURE = """
|
||||
[pycalver]
|
||||
[calver]
|
||||
current_version = "v201808.1456-beta"
|
||||
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||
commit_message = "bump version to {new_version}"
|
||||
|
|
@ -72,7 +95,7 @@ commit = True
|
|||
tag = True
|
||||
push = True
|
||||
|
||||
[pycalver:file_patterns]
|
||||
[calver:file_patterns]
|
||||
setup.py =
|
||||
{version}
|
||||
{pep440_version}
|
||||
|
|
@ -103,17 +126,18 @@ def test_parse_toml_1():
|
|||
raw_cfg = config._parse_toml(buf)
|
||||
cfg = config._parse_config(raw_cfg)
|
||||
|
||||
assert cfg.current_version == "v201808.0123-alpha"
|
||||
assert cfg.version_pattern == "{pycalver}"
|
||||
assert cfg.current_version == "v2020.1003-alpha"
|
||||
assert cfg.version_pattern == "vYYYY.BUILD[-TAG]"
|
||||
assert cfg.commit is True
|
||||
assert cfg.tag is True
|
||||
assert cfg.push is True
|
||||
|
||||
assert "pycalver.toml" in cfg.file_patterns
|
||||
files = set(cfg.file_patterns)
|
||||
assert "pycalver.toml" in files
|
||||
|
||||
raw_patterns_by_filepath = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_filepath["README.md" ] == ["{pycalver}", "{pep440_pycalver}"]
|
||||
assert raw_patterns_by_filepath["pycalver.toml"] == ['current_version = "{pycalver}"']
|
||||
raw_patterns_by_path = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_path["README.md" ] == ["vYYYY.BUILD[-TAG]", "YYYY.BLD[PYTAGNUM]"]
|
||||
assert raw_patterns_by_path["pycalver.toml"] == ['current_version = "vYYYY.BUILD[-TAG]"']
|
||||
|
||||
|
||||
def test_parse_toml_2():
|
||||
|
|
@ -130,9 +154,29 @@ def test_parse_toml_2():
|
|||
|
||||
assert "pycalver.toml" in cfg.file_patterns
|
||||
|
||||
raw_patterns_by_filepath = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_filepath["README.md" ] == ["{semver}", "{semver}"]
|
||||
assert raw_patterns_by_filepath["pycalver.toml"] == ['current_version = "{semver}"']
|
||||
raw_patterns_by_path = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_path["README.md" ] == ["{semver}", "{semver}"]
|
||||
assert raw_patterns_by_path["pycalver.toml"] == ['current_version = "{semver}"']
|
||||
|
||||
|
||||
def test_parse_toml_3():
|
||||
buf = mk_buf(CALVER_TOML_FIXTURE_3)
|
||||
|
||||
raw_cfg = config._parse_toml(buf)
|
||||
cfg = config._parse_config(raw_cfg)
|
||||
|
||||
assert cfg.current_version == "v201808.0123-alpha"
|
||||
assert cfg.version_pattern == "vYYYY0M.BUILD[-TAG]"
|
||||
assert cfg.commit is True
|
||||
assert cfg.tag is True
|
||||
assert cfg.push is True
|
||||
|
||||
files = set(cfg.file_patterns)
|
||||
assert "calver.toml" in files
|
||||
|
||||
raw_patterns_by_path = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_path["README.md" ] == ["vYYYY0M.BUILD[-TAG]", "YYYY0M.BLD[PYTAGNUM]"]
|
||||
assert raw_patterns_by_path["calver.toml"] == ['current_version = "vYYYY0M.BUILD[-TAG]"']
|
||||
|
||||
|
||||
def test_parse_v1_cfg():
|
||||
|
|
@ -146,11 +190,12 @@ def test_parse_v1_cfg():
|
|||
assert cfg.tag is True
|
||||
assert cfg.push is True
|
||||
|
||||
assert "setup.cfg" in cfg.file_patterns
|
||||
files = set(cfg.file_patterns)
|
||||
assert "setup.cfg" in files
|
||||
|
||||
raw_patterns_by_filepath = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_filepath["setup.py" ] == ["{pycalver}", "{pep440_pycalver}"]
|
||||
assert raw_patterns_by_filepath["setup.cfg"] == ['current_version = "{pycalver}"']
|
||||
raw_patterns_by_path = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_path["setup.py" ] == ["vYYYY0M.BUILD[-TAG]", "YYYY0M.BLD[PYTAGNUM]"]
|
||||
assert raw_patterns_by_path["setup.cfg"] == ['current_version = "vYYYY0M.BUILD[-TAG]"']
|
||||
|
||||
|
||||
def test_parse_v2_cfg():
|
||||
|
|
@ -164,16 +209,14 @@ def test_parse_v2_cfg():
|
|||
assert cfg.tag is True
|
||||
assert cfg.push is True
|
||||
|
||||
assert "setup.py" in cfg.file_patterns
|
||||
assert "setup.cfg" in cfg.file_patterns
|
||||
files = set(cfg.file_patterns)
|
||||
assert "setup.py" in files
|
||||
assert "setup.cfg" in files
|
||||
|
||||
raw_patterns_by_filepath = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_filepath["setup.py"] == [
|
||||
"vYYYY0M.BUILD[-TAG]",
|
||||
"YYYY0M.BLD[PYTAGNUM]",
|
||||
]
|
||||
assert raw_patterns_by_filepath["setup.cfg"] == ['current_version = "vYYYY0M.BUILD[-TAG]"']
|
||||
assert raw_patterns_by_filepath["src/project/*.py"] == ["Copyright (c) 2018-YYYY"]
|
||||
raw_patterns_by_path = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_path["setup.py"] == ["vYYYY0M.BUILD[-TAG]", "YYYY0M.BLD[PYTAGNUM]"]
|
||||
assert raw_patterns_by_path["setup.cfg"] == ['current_version = "vYYYY0M.BUILD[-TAG]"']
|
||||
assert raw_patterns_by_path["src/project/*.py"] == ["Copyright (c) 2018-YYYY"]
|
||||
|
||||
|
||||
def test_parse_default_toml():
|
||||
|
|
@ -204,8 +247,8 @@ def test_parse_default_cfg():
|
|||
|
||||
def test_parse_project_toml():
|
||||
project_path = util.FIXTURES_DIR / "project_a"
|
||||
config_path = util.FIXTURES_DIR / "project_a" / "pycalver.toml"
|
||||
config_rel_path = "pycalver.toml"
|
||||
config_path = util.FIXTURES_DIR / "project_a" / "calver.toml"
|
||||
config_rel_path = "calver.toml"
|
||||
|
||||
with config_path.open() as fobj:
|
||||
config_data = fobj.read()
|
||||
|
|
@ -224,7 +267,8 @@ def test_parse_project_toml():
|
|||
assert cfg.tag is True
|
||||
assert cfg.push is True
|
||||
|
||||
assert set(cfg.file_patterns.keys()) == {"pycalver.toml", "README.md"}
|
||||
files = set(cfg.file_patterns.keys())
|
||||
assert files == {"calver.toml", "README.md"}
|
||||
|
||||
|
||||
def test_parse_project_cfg():
|
||||
|
|
@ -258,25 +302,26 @@ def test_parse_project_cfg():
|
|||
|
||||
def test_parse_toml_file(tmpdir):
|
||||
project_path = tmpdir.mkdir("minimal")
|
||||
setup_cfg = project_path.join("pycalver.toml")
|
||||
setup_cfg.write(PYCALVER_TOML_FIXTURE_1)
|
||||
setup_cfg_rel_path = "pycalver.toml"
|
||||
cfg_file = project_path.join("pycalver.toml")
|
||||
cfg_file.write(PYCALVER_TOML_FIXTURE_1)
|
||||
cfg_file_rel_path = "pycalver.toml"
|
||||
|
||||
ctx = config.init_project_ctx(project_path)
|
||||
assert ctx == config.ProjectContext(project_path, setup_cfg, setup_cfg_rel_path, 'toml', None)
|
||||
assert ctx == config.ProjectContext(project_path, cfg_file, cfg_file_rel_path, 'toml', None)
|
||||
|
||||
cfg = config.parse(ctx)
|
||||
|
||||
assert cfg
|
||||
assert cfg.current_version == "v201808.0123-alpha"
|
||||
assert cfg.current_version == "v2020.1003-alpha"
|
||||
assert cfg.version_pattern == "vYYYY.BUILD[-TAG]"
|
||||
assert cfg.tag is True
|
||||
assert cfg.commit is True
|
||||
assert cfg.push is True
|
||||
|
||||
raw_patterns_by_filepath = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_filepath == {
|
||||
"README.md" : ["{pycalver}", "{pep440_pycalver}"],
|
||||
"pycalver.toml": ['current_version = "{pycalver}"'],
|
||||
"README.md" : ["vYYYY.BUILD[-TAG]", "YYYY.BLD[PYTAGNUM]"],
|
||||
"pycalver.toml": ['current_version = "vYYYY.BUILD[-TAG]"'],
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -294,6 +339,8 @@ def test_parse_default_pattern():
|
|||
assert cfg
|
||||
|
||||
assert cfg.current_version == "v2017q1.54321"
|
||||
# assert cfg.version_pattern == "vYYYYqQ.BUILD"
|
||||
assert cfg.version_pattern == "v{year}q{quarter}.{build_no}"
|
||||
assert cfg.commit is True
|
||||
assert cfg.tag is True
|
||||
assert cfg.push is True
|
||||
|
|
@ -317,14 +364,15 @@ def test_parse_cfg_file(tmpdir):
|
|||
|
||||
assert cfg
|
||||
assert cfg.current_version == "v201808.0456-beta"
|
||||
assert cfg.version_pattern == "vYYYY0M.BUILD[-TAG]"
|
||||
assert cfg.tag is True
|
||||
assert cfg.commit is True
|
||||
assert cfg.push is True
|
||||
|
||||
raw_patterns_by_filepath = _parse_raw_patterns_by_filepath(cfg)
|
||||
assert raw_patterns_by_filepath == {
|
||||
"setup.py" : ["{pycalver}", "{pep440_pycalver}"],
|
||||
"setup.cfg": ['current_version = "{pycalver}"'],
|
||||
"setup.py" : ["vYYYY0M.BUILD[-TAG]", "YYYY0M.BLD[PYTAGNUM]"],
|
||||
"setup.cfg": ['current_version = "vYYYY0M.BUILD[-TAG]"'],
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -358,7 +406,7 @@ def test_parse_missing_version(tmpdir):
|
|||
setup_path.write(
|
||||
"\n".join(
|
||||
(
|
||||
"[pycalver]",
|
||||
"[calver]",
|
||||
# f"current_version = v201808.1001-dev",
|
||||
"commit = False",
|
||||
)
|
||||
|
|
@ -374,7 +422,7 @@ def test_parse_missing_version(tmpdir):
|
|||
|
||||
def test_parse_invalid_version(tmpdir):
|
||||
setup_path = tmpdir.mkdir("fail").join("setup.cfg")
|
||||
setup_path.write("\n".join(("[pycalver]", "current_version = 0.1.0", "commit = False")))
|
||||
setup_path.write("\n".join(("[calver]", "current_version = 0.1.0", "commit = False")))
|
||||
|
||||
ctx = config.init_project_ctx(setup_path)
|
||||
assert ctx
|
||||
|
|
|
|||
|
|
@ -95,13 +95,14 @@ def test_v1_rewrite_final():
|
|||
def test_iter_file_paths():
|
||||
with util.Project(project="a") as project:
|
||||
ctx = config.init_project_ctx(project.dir)
|
||||
assert ctx
|
||||
cfg = config.parse(ctx)
|
||||
assert cfg
|
||||
|
||||
_paths_and_patterns = rewrite.iter_path_patterns_items(cfg.file_patterns)
|
||||
file_paths = {str(file_path) for file_path, patterns in _paths_and_patterns}
|
||||
|
||||
assert file_paths == {"pycalver.toml", "README.md"}
|
||||
assert file_paths == {"calver.toml", "README.md"}
|
||||
|
||||
|
||||
def test_iter_file_globs():
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ FIXTURE_PATH_PARTS = [
|
|||
["setup.cfg"],
|
||||
["setup.py"],
|
||||
["pycalver.toml"],
|
||||
["calver.toml"],
|
||||
["src", "module_v1", "__init__.py"],
|
||||
["src", "module_v2", "__init__.py"],
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue