Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyphens vs underscores: the bug reported in #127. #128

Merged
merged 7 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ repos:
hooks:
- id: ruff
args: ["--config", "pyproject.toml"]
exclude: "{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}"
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
Expand All @@ -27,6 +28,7 @@ repos:
- id: mypy
args: [--config-file, pyproject.toml]
additional_dependencies: ["pytest"]
exclude: "{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}"
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
Expand Down
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"github_username": "{{ cookiecutter.author_name.replace(' ', '-') }}",
"project_name": "Python Template",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '-').replace('_', '-') }}",
"package_name": "{{ cookiecutter.project_slug.replace('-', '_') }}",
"project_short_description": "A cookiecutter template with ARC recommendations.",
"funder": "JBFC: The Joe Bloggs Funding Council",
"license": ["MIT", "BSD-3", "GPL-3.0"],
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ def project_config():
as defined in the cookiecutter.json
"""
return {
"project_slug": "cookiecutter_test",
"project_name": "Cookiecutter Test",
"expected_repo_name": "cookiecutter-test",
"expected_package_name": "cookiecutter_test",
}
17 changes: 10 additions & 7 deletions tests/test_package_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,34 @@ def test_package_generation(
"--no-input",
"--output-dir",
str(tmp_path),
f"project_slug={project_config['project_slug']}",
f"project_name={project_config['project_name']}",
],
check=False,
shell=False, # noqa: S603
)

test_project_dir = tmp_path / project_config["project_slug"]

# Check parent directory exists
# Check project directory exists
test_project_dir = tmp_path / project_config["expected_repo_name"]
assert test_project_dir.exists()

# Check main files and directories inside parent directory
# Check main files and directories inside
expected_files = [
"README.md",
".pre-commit-config.yaml",
"LICENSE.md",
"pyproject.toml",
"src",
Path("src") / project_config["project_slug"],
Path("src") / project_config["expected_package_name"],
Path("src") / project_config["expected_package_name"] / "__init__.py",
"tests",
Path(".github"),
Path(".github") / "workflows",
]
for f in expected_files:
assert (test_project_dir / f).exists()
full_path = test_project_dir / f
assert (
full_path.exists()
), f"Expected file/folder: {full_path}, but didn't find it."

# Need a .git directory in the project root
subprocess.run(["git", "init", test_project_dir], check=False) # noqa: S603,S607
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pep8-naming.classmethod-decorators = [

[tool.setuptools_scm]
local_scheme = "no-local-version"
write_to = "src/{{ cookiecutter.project_slug }}/_version.py"
write_to = "src/{{ cookiecutter.package_name }}/_version.py"

[tool.tomlsort]
all = true
Expand Down