From 96cb29ef030b7dd032c64491afe25e25fe48a3c2 Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Mon, 8 Apr 2024 17:37:12 +0200 Subject: [PATCH 1/2] Fix Created: datetime in spdx output Signed-off-by: Carmen Bianca BAKKER --- poetry.lock | 44 +++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + src/reuse/report.py | 3 +-- tests/test_main.py | 3 +++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 8e508484..6ecbe537 100644 --- a/poetry.lock +++ b/poetry.lock @@ -483,6 +483,21 @@ docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1 testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] typing = ["typing-extensions (>=4.8)"] +[[package]] +name = "freezegun" +version = "1.4.0" +description = "Let your Python tests travel through time" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "freezegun-1.4.0-py3-none-any.whl", hash = "sha256:55e0fc3c84ebf0a96a5aa23ff8b53d70246479e9a68863f1fcac5a3e52f19dd6"}, + {file = "freezegun-1.4.0.tar.gz", hash = "sha256:10939b0ba0ff5adaecf3b06a5c2f73071d9678e507c5eaedb23c761d56ac774b"}, +] + +[package.dependencies] +python-dateutil = ">=2.7" + [[package]] name = "furo" version = "2024.1.29" @@ -1062,6 +1077,21 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] +[[package]] +name = "python-dateutil" +version = "2.9.0.post0" +description = "Extensions to the standard Python datetime module" +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, + {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, +] + +[package.dependencies] +six = ">=1.5" + [[package]] name = "python-debian" version = "0.1.49" @@ -1277,6 +1307,18 @@ docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + [[package]] name = "smmap" version = "5.0.1" @@ -1647,4 +1689,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "f9316ba566a778a7e9aefd50493e80445a7c4ffa04287a06d305ab691ffaae52" +content-hash = "90191ded4582d463c4bcacea2678412b4094a81c4b2cfe10396231af44ea73d2" diff --git a/pyproject.toml b/pyproject.toml index b696b489..4e48925a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,7 @@ python-debian = "^0.1.34,!=0.1.45,!=0.1.46,!=0.1.47" [tool.poetry.group.test.dependencies] pytest = ">=6.0.0" pytest-cov = ">=2.10.0" +freezegun = "^1.0.0" [tool.poetry.group.docs.dependencies] Sphinx = ">=4.0.0" diff --git a/src/reuse/report.py b/src/reuse/report.py index a3b42f01..169e1dc5 100644 --- a/src/reuse/report.py +++ b/src/reuse/report.py @@ -228,8 +228,7 @@ def bill_of_materials( out.write(f"Creator: Tool: reuse-{__version__}\n") now = datetime.datetime.now(tz=datetime.timezone.utc) - now = now.replace(microsecond=0) - out.write(f"Created: {now.isoformat()}Z\n") + out.write(f"Created: {now.strftime('%Y-%m-%dT%H:%M:%SZ')}\n") out.write( "CreatorComment: This document was created automatically" " using available reuse information consistent with" diff --git a/tests/test_main.py b/tests/test_main.py index 0ee42dd1..1df86a55 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -22,6 +22,7 @@ from urllib.error import URLError import pytest +from freezegun import freeze_time from reuse import download from reuse._main import main @@ -336,6 +337,7 @@ def test_lint_no_multiprocessing(fake_repository, stringio, multiprocessing): assert ":-)" in stringio.getvalue() +@freeze_time("2024-04-08T17:34:00Z") def test_spdx(fake_repository, stringio): """Compile to an SPDX document.""" os.chdir(str(fake_repository)) @@ -347,6 +349,7 @@ def test_spdx(fake_repository, stringio): assert "\nLicenseConcluded: GPL-3.0-or-later\n" not in output assert "\nCreator: Person: Anonymous ()\n" in output assert "\nCreator: Organization: Anonymous ()\n" in output + assert "\nCreated: 2024-04-08T17:34:00Z\n" in output # TODO: This test is rubbish. assert result == 0 From 87e5ed5d45acc7f407d289d92ce40a76762d6c15 Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Mon, 8 Apr 2024 17:45:40 +0200 Subject: [PATCH 2/2] Add change log entry Signed-off-by: Carmen Bianca BAKKER --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ce616b..296fc2e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,8 @@ CLI command and its behaviour. There are no guarantees of stability for the - Clearer instructions for `--suppress-deprecation` in deprecation warning. (#949) +- The datetime value for `Created:` was wrongly formatted since 3.0.0. It now + returns a correctly formatted ISO 8601 date again. (#952) ### Security