Skip to content

Commit abc6f07

Browse files
Move core configuration tests to vcs-versioning
Split setuptools-scm/testing_scm/test_config.py by moving core Configuration tests to vcs-versioning/testing_vcs/test_config.py. Moved tests: - test_tag_regex: tests Configuration tag_regex matching (core) - test_config_regex_init: tests Configuration initialization with regex (core) - test_config_bad_regex: tests Configuration validation (core) Kept in setuptools-scm: - test_config_from_pyproject: Configuration.from_file (setuptools integration) - test_config_from_file_protects_relative_to: from_file warning (setuptools integration) - test_config_overrides: from_file with env overrides (setuptools integration) All tests pass: 407 passed, 10 skipped, 1 xfailed
1 parent 7f905b4 commit abc6f07

File tree

2 files changed

+61
-49
lines changed

2 files changed

+61
-49
lines changed
Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
"""Tests for setuptools-scm specific Configuration functionality.
2+
3+
Core Configuration tests have been moved to vcs-versioning/testing_vcs/test_config.py
4+
"""
5+
16
from __future__ import annotations
27

3-
import re
48
import textwrap
59

610
from pathlib import Path
@@ -10,28 +14,6 @@
1014
from setuptools_scm import Configuration
1115

1216

13-
@pytest.mark.parametrize(
14-
("tag", "expected_version"),
15-
[
16-
("apache-arrow-0.9.0", "0.9.0"),
17-
("arrow-0.9.0", "0.9.0"),
18-
("arrow-0.9.0-rc", "0.9.0-rc"),
19-
("arrow-1", "1"),
20-
("arrow-1+", "1"),
21-
("arrow-1+foo", "1"),
22-
("arrow-1.1+foo", "1.1"),
23-
("v1.1", "v1.1"),
24-
("V1.1", "V1.1"),
25-
],
26-
)
27-
def test_tag_regex(tag: str, expected_version: str) -> None:
28-
config = Configuration()
29-
match = config.tag_regex.match(tag)
30-
assert match
31-
version = match.group("version")
32-
assert version == expected_version
33-
34-
3517
def test_config_from_pyproject(tmp_path: Path) -> None:
3618
fn = tmp_path / "pyproject.toml"
3719
fn.write_text(
@@ -48,12 +30,6 @@ def test_config_from_pyproject(tmp_path: Path) -> None:
4830
Configuration.from_file(str(fn))
4931

5032

51-
def test_config_regex_init() -> None:
52-
tag_regex = re.compile(r"v(\d+)")
53-
conf = Configuration(tag_regex=tag_regex)
54-
assert conf.tag_regex is tag_regex
55-
56-
5733
def test_config_from_file_protects_relative_to(tmp_path: Path) -> None:
5834
fn = tmp_path / "pyproject.toml"
5935
fn.write_text(
@@ -98,23 +74,3 @@ def test_config_overrides(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> No
9874

9975
assert pristine.root != overridden.root
10076
assert pristine.fallback_root != overridden.fallback_root
101-
102-
103-
@pytest.mark.parametrize(
104-
"tag_regex",
105-
[
106-
r".*",
107-
r"(.+)(.+)",
108-
r"((.*))",
109-
],
110-
)
111-
def test_config_bad_regex(tag_regex: str) -> None:
112-
with pytest.raises(
113-
ValueError,
114-
match=(
115-
f"Expected tag_regex '{re.escape(tag_regex)}' to contain a single match"
116-
" group or a group named 'version' to identify the version part of any"
117-
" tag."
118-
),
119-
):
120-
Configuration(tag_regex=re.compile(tag_regex))
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""Tests for core Configuration functionality."""
2+
3+
from __future__ import annotations
4+
5+
import re
6+
7+
import pytest
8+
from setuptools_scm import Configuration
9+
10+
11+
@pytest.mark.parametrize(
12+
("tag", "expected_version"),
13+
[
14+
("apache-arrow-0.9.0", "0.9.0"),
15+
("arrow-0.9.0", "0.9.0"),
16+
("arrow-0.9.0-rc", "0.9.0-rc"),
17+
("arrow-1", "1"),
18+
("arrow-1+", "1"),
19+
("arrow-1+foo", "1"),
20+
("arrow-1.1+foo", "1.1"),
21+
("v1.1", "v1.1"),
22+
("V1.1", "V1.1"),
23+
],
24+
)
25+
def test_tag_regex(tag: str, expected_version: str) -> None:
26+
config = Configuration()
27+
match = config.tag_regex.match(tag)
28+
assert match
29+
version = match.group("version")
30+
assert version == expected_version
31+
32+
33+
def test_config_regex_init() -> None:
34+
tag_regex = re.compile(r"v(\d+)")
35+
conf = Configuration(tag_regex=tag_regex)
36+
assert conf.tag_regex is tag_regex
37+
38+
39+
@pytest.mark.parametrize(
40+
"tag_regex",
41+
[
42+
r".*",
43+
r"(.+)(.+)",
44+
r"((.*))",
45+
],
46+
)
47+
def test_config_bad_regex(tag_regex: str) -> None:
48+
with pytest.raises(
49+
ValueError,
50+
match=(
51+
f"Expected tag_regex '{re.escape(tag_regex)}' to contain a single match"
52+
" group or a group named 'version' to identify the version part of any"
53+
" tag."
54+
),
55+
):
56+
Configuration(tag_regex=re.compile(tag_regex))

0 commit comments

Comments
 (0)