From fa485b2e614f6d7bead340d696155e87cd0ae956 Mon Sep 17 00:00:00 2001 From: Manuel Barkhau Date: Fri, 29 Mar 2019 21:24:47 +0100 Subject: [PATCH] Add tests for default pattern --- test/fixtures/project_c/pyproject.toml | 6 ++++++ test/test_config.py | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/fixtures/project_c/pyproject.toml diff --git a/test/fixtures/project_c/pyproject.toml b/test/fixtures/project_c/pyproject.toml new file mode 100644 index 0000000..e460fb7 --- /dev/null +++ b/test/fixtures/project_c/pyproject.toml @@ -0,0 +1,6 @@ +[pycalver] +current_version = "v2017q1.54321" +version_pattern = "v{year}q{quarter}.{build_no}" +commit = true +tag = true +push = true diff --git a/test/test_config.py b/test/test_config.py index 775b3e9..2e5e7b8 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -212,6 +212,28 @@ def test_parse_toml_file(tmpdir): } +def test_parse_default_pattern(tmpdir): + project_path = util.FIXTURES_DIR / "project_c" + config_path = util.FIXTURES_DIR / "project_c" / "pyproject.toml" + + ctx = config.init_project_ctx(project_path) + + assert ctx == config.ProjectContext(project_path, config_path, "toml", None) + + cfg = config.parse(ctx) + + assert cfg + + assert cfg.current_version == "v2017q1.54321" + assert cfg.commit is True + assert cfg.tag is True + assert cfg.push is True + + assert cfg.file_patterns == { + "pyproject.toml": [r'current_version = "v{year}q{quarter}.{build_no}"'] + } + + def test_parse_cfg_file(tmpdir): project_path = tmpdir.mkdir("minimal") setup_cfg = project_path.join("setup.cfg")