From 9978e3f35d28791eea8f13e61256a7b399da9137 Mon Sep 17 00:00:00 2001 From: Jelmer Draaijer Date: Sun, 27 Oct 2024 11:32:43 +0100 Subject: [PATCH] Update pyproject.toml project information and PEP-735 --- tests/test_cookiecutter_generation.py | 25 ++++++++++++++++++++ {{cookiecutter.project_slug}}/pyproject.toml | 14 +++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 082c3cba..7ad8bffa 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -2,6 +2,7 @@ import glob import os import re import sys +import tomllib import pytest @@ -412,3 +413,27 @@ def test_trim_domain_email(cookies, context): base_settings = result.project_path / "config" / "settings" / "base.py" assert '"me@example.com"' in base_settings.read_text() + + +def test_pyproject_toml(cookies, context): + author_name = "Project Author" + author_email = "me@example.com" + context.update( + { + "description": "DESCRIPTION", + "domain_name": "example.com", + "email": author_email, + "author_name": author_name, + } + ) + result = cookies.bake(extra_context=context) + assert result.exit_code == 0 + + pyproject_toml = result.project_path / "pyproject.toml" + + data = tomllib.loads(pyproject_toml.read_text()) + + assert data + assert data["project"]["authors"][0]["email"] == author_email + assert data["project"]["authors"][0]["name"] == author_name + assert data["project"]["name"] == context["project_slug"] diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 2c00f78c..f261223b 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -141,8 +141,8 @@ extend-unsafe-fixes = [ [tool.ruff.lint.isort] force-single-line = true -[tool.uv] -dev-dependencies = [ +[dependency-groups] +dev = [ "Werkzeug[watchdog]==3.0.6", # https://github.com/pallets/werkzeug "ipdb==0.13.13", # https://github.com/gotcha/ipdb {%- if cookiecutter.use_docker == 'y' %} @@ -182,14 +182,14 @@ dev-dependencies = [ ] [project] -name = "cookiecutter-django" -version = "2024.10.04" -description = "A Cookiecutter template for creating production-ready Django projects quickly." +name = "{{ cookiecutter.project_slug }}" +version = "{{ cookiecutter.version }}" +description = "{{ cookiecutter.description }}" readme = "README.md" -license = { text = "BSD" } +license = { text = "{{ cookiecutter.open_source_license }}" } authors = [ - { name = "Daniel Roy Greenfeld", email = "pydanny@gmail.com" }, + { name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.email }}" }, ] requires-python = "==3.12.*" dependencies = [