`tests/data/test_package_generation` fails every new year as the year is hardcoded
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- testing-qa, tooling
Rechercherichtung
Start with tests/test_package_generation.py and the reference files under tests/data/test_package_generation. Run the package-generation test and inspect the year differences in mkdocs.yml and LICENSE.md. Done means the generated package and expected data remain consistent when the calendar year changes.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the Bug
Every year the regression test will generate a package based on the current year when the test files will have the previous year
To Reproduce
Wait until a new year and watch tests fail on a PR
Expected Behaviour
Ideally we could either ignore the year or update the year somehow with @renovatebot or something
Actual Behaviour
============================= test session starts ==============================
platform linux -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0 -- /home/runner/work/python-tooling/python-tooling/.tox/py312/bin/python
cachedir: .tox/py312/.pytest_cache
rootdir: /home/runner/work/python-tooling/python-tooling
configfile: pyproject.toml
collecting ... collected 8 items
tests/data/test_package_generation/tests/test_dummy.py::test_stupid_example PASSED [ 12%]
tests/test_git_init.py::test_initialisation_of_git_repo[True] PASSED [ 25%]
tests/test_git_init.py::test_initialisation_of_git_repo[False] PASSED [ 37%]
tests/test_package_generation.py::test_package_generation FAILED [ 50%]
tests/test_package_generation.py::test_pip_installable PASSED [ 62%]
tests/test_package_generation.py::test_optional_funder[] PASSED [ 75%]
tests/test_package_generation.py::test_optional_funder[STFC] PASSED [ 87%]
{{cookiecutter.project_slug}}/tests/test_dummy.py::test_stupid_example PASSED [100%]
=================================== FAILURES ===================================
___________________________ test_package_generation ____________________________
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/test_package_generation0')
generate_package = <function _generate_package at 0x7fa89eb311c0>
def test_package_generation(
tmp_path: pathlib.Path,
generate_package: typing.Callable,
) -> None:
"""Test package generation."""
test_config = {
"github_owner": "test-user",
"project_short_description": "description",
"project_name": "Cookiecutter Test",
# Not having a git repo makes it easier to check in/out reference
# data files to the main python-tooling git repository
"initialise_git_repository": False,
}
generate_package(config=test_config, path=tmp_path)
expected_package_dir = (
pathlib.Path(__file__).parent / "data" / "test_package_generation"
)
# Check project directory exists
test_project_dir = tmp_path / "cookiecutter-test"
assert test_project_dir.exists()
actual_files = get_all_files_folders(test_project_dir)
expected_files = get_all_files_folders(expected_package_dir)
assert actual_files == expected_files
# Check diff between actual and expected file contents
diff = ""
for file in actual_files:
actual_file = test_project_dir / file
expected_file = expected_package_dir / file
if actual_file.is_dir():
continue
with actual_file.open() as f1, expected_file.open() as f2:
diff += "".join(
difflib.unified_diff(
f1.readlines(),
f2.readlines(),
fromfile=str(actual_file),
tofile=str(expected_file),
)
)
if diff:
shutil.rmtree(expected_package_dir)
shutil.move(test_project_dir, expected_package_dir)
msg = (
"Non-zero diff between generated files and expected files.\n"
"Test data files have been modified with new content.\n"
"Diff is:\n"
f"{diff}"
)
> raise RuntimeError(msg)
E RuntimeError: Non-zero diff between generated files and expected files.
E Test data files have been modified with new content.
E Diff is:
E --- /tmp/pytest-of-runner/pytest-0/test_package_generation0/cookiecutter-test/mkdocs.yml
E +++ /home/runner/work/python-tooling/python-tooling/tests/data/test_package_generation/mkdocs.yml
E @@ -1,7 +1,7 @@
E site_name: "Cookiecutter Test"
E site_description: "Documentation website for Cookiecutter Test"
E site_author: "Eva Lu Ator"
E -copyright: "Copyright © 2025 Eva Lu Ator"
E +copyright: "Copyright © 2024 Eva Lu Ator"
E repo_url: "https://github.com/test-user/cookiecutter-test/"
E repo_name: "test-user/cookiecutter-test"
E edit_uri: edit/main/docs/
E --- /tmp/pytest-of-runner/pytest-0/test_package_generation0/cookiecutter-test/LICENSE.md
E +++ /home/runner/work/python-tooling/python-tooling/tests/data/test_package_generation/LICENSE.md
E @@ -1,6 +1,6 @@
E <!-- markdownlint-disable MD041 --># MIT License
E
E -Copyright (c) 2025 Eva Lu Ator
E +Copyright (c) 2024 Eva Lu Ator
E
E Permission is hereby granted, free of charge, to any person obtaining a copy of
Version In Use
v1.0.0
Additional Context
- Vorherrschende Sprache
- Python
- Sterne
- 62
- Forks
- 10
- Ø Merge
- 5 T. 19 Std.
- Gemergte PRs (30 T.)
- 6
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus UCL-ARC/python-tooling
-
question
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 15/100
UCL-ARC/python-tooling#657 · 1 Kommentar ·
-
task
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
UCL-ARC/python-tooling#651 · 3 Kommentare ·
-
Should we have an AI policy?Evtl. vergeben @samcunliffe hat das vor 26 Tagen übernommen. Offenquestion
UCL-ARC/python-tooling#649 · 3 Kommentare · 1 zugewiesene Person ·
-
enhancement investigate
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
UCL-ARC/python-tooling#623 · 1 Reaktion ·
-
enhancement question task
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 38/100
UCL-ARC/python-tooling#620 · 4 Kommentare ·
Alle Issues in UCL-ARC/python-tooling
Ähnliche Issues
-
Import errors are swallowed: PerthImplicitWatermarker silently becomes NoneEvtl. vergeben @JonRC hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
resemble-ai/Perth#23 ·
-
correction metadata
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
acl-org/acl-anthology#10753 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
earthtojake/text-to-cad#758 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 70/100
DataTalksClub/faq#545 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag