File: pyproject-add-version.diff

package info (click to toggle)
python-logistro 2.0.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: python: 350; makefile: 4
file content (57 lines) | stat: -rw-r--r-- 2,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@
 [project]
 name = "logistro"
 description = "Simple wrapper over logging for a couple basic features"
-dynamic = ["version"]
+version = "2.0.1"
 readme = "README.md"
 license = { "file" = "LICENSE" }
 requires-python = ">=3.8"
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,8 @@
+import pytest
+
+@pytest.fixture
+def project_root(request):
+    return request.config.getoption("--project-root")
+
+def pytest_addoption(parser):
+    parser.addoption("--project-root", action="store", default=None, help="Project root directory")
--- /dev/null
+++ b/tests/test_version.py
@@ -0,0 +1,32 @@
+import importlib.metadata
+import re
+import pathlib
+
+import logistro
+
+
+def test_version_matches_debian_package(project_root):
+    """
+    Test that logistro version metadata matches the Debian package version.
+
+    This is a check that the maintainer remembered to update the version in debian/patches/pyproject-add-version.diff when releasing a new version.
+    The patch is needed becaue upstream depends on setuptools-git-versioning, which is not available in Debian.
+    """
+    # Get version from python
+    version_from_python = importlib.metadata.version("logistro")
+
+    # Read debian/changelog and extract the version
+    if project_root is not None:
+        changelog_path = pathlib.Path(project_root) / "debian" / "changelog"
+    else:
+        changelog_path = pathlib.Path(__file__).parent.parent / "debian" / "changelog"
+    changelog_content = changelog_path.read_text()
+    match = re.search(r"python-logistro \(([^)]+)\)", changelog_content)
+    assert match, "Could not find version in debian/changelog"
+    version_from_debian, _ = match.group(1).split("+")
+
+    # Compare the two versions
+    assert version_from_python == version_from_debian, (
+        f"Version in pyproject.toml ({version_from_python}) does not match "
+        f"Debian version ({version_from_debian}). Please update debian/patches/pyproject-add-version.diff to set the correct version."
+    )