Skip to content

Commit

Permalink
Merge pull request #952 from carmenbianca/fix-time-spdx
Browse files Browse the repository at this point in the history
Fix Created: datetime in spdx output
  • Loading branch information
carmenbianca authored Apr 8, 2024
2 parents 0426f12 + 87e5ed5 commit cc69fa7
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
44 changes: 43 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/reuse/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <text>This document was created automatically"
" using available reuse information consistent with"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down

0 comments on commit cc69fa7

Please sign in to comment.