Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ assignees: ''
**Bug report**


**Environment Information**


**Before submitting**
Please check the following:

- [ ] I have described the situation in which the bug arose, including what code was executed, information about my environment, and any applicable data others will need to reproduce the problem.
- [ ] I have described the situation in which the bug arose, including what code was executed, and any applicable data others will need to reproduce the problem.
- [ ] I have included information about my environment, including the version of this package (e.g. `{{package_name}}.__version__`)
- [ ] I have included available evidence of the unexpected behavior (including error messages, screenshots, and/or plots) as well as a description of what I expected instead.
- [ ] If I have a solution in mind, I have provided an explanation and/or pseudocode and/or task list.
2 changes: 1 addition & 1 deletion python-project-template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "MIT"
license = "GPL-3.0-only"
{%- endif %}
{%- if project_license != 'none' %}
license_file = ["LICENSE"]
license-files = ["LICENSE"]
{%- endif %}
readme = "README.md"
authors = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{%- if create_example_module -%}
from ._version import __version__
{% if create_example_module -%}
from .example_module import greetings, meaning

__all__ = ["greetings", "meaning"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {{package_name}}


def test_version():
"""Check to see that we can get the package version"""
assert {{package_name}}.__version__ is not None
30 changes: 11 additions & 19 deletions tests/test_package_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def create_project_with_basic_checks(copie, extra_answers, package_name="example
result.exit_code == 0 and result.exception is None and result.project_dir.is_dir()
), "Did not successfully create project"

# install the `example_package` into the existing python environment.
build_results = subprocess.run(
["python", "-m", "pip", "install", "--no-deps", "."], cwd=result.project_dir, check=False
)
assert build_results.returncode == 0

# pyproject_toml_is_valid
precommit_results = subprocess.run(
["pre-commit", "run", "validate-pyproject"], cwd=result.project_dir, check=False
Expand Down Expand Up @@ -48,19 +54,16 @@ def create_project_with_basic_checks(copie, extra_answers, package_name="example
print("Required file not generated:", file)
assert all_found

return result


def black_runs_successfully(result):
"""Test to ensure that the black linter runs successfully on the project"""
# run black with `--check` to look for lint errors, but don't fix them.
# black_runs_successfully
black_results = subprocess.run(
["python", "-m", "black", "--check", (result.project_dir / "src")],
cwd=result.project_dir,
check=False,
)

return black_results.returncode == 0
assert black_results.returncode == 0

return result


def pylint_runs_successfully(result):
Expand Down Expand Up @@ -123,6 +126,7 @@ def test_all_defaults(copie):
# run copier to hydrate a temporary project
result = create_project_with_basic_checks(copie, {})

# uses ruff instead of (black/isort/pylint)
assert not pylint_runs_successfully(result)

# check to see if the README file was hydrated with copier answers.
Expand Down Expand Up @@ -161,8 +165,6 @@ def test_use_black_and_no_example_modules(copie):
break
assert found_line

assert black_runs_successfully(result)


@pytest.mark.parametrize(
"enforce_style",
Expand All @@ -187,9 +189,6 @@ def test_code_style_combinations(copie, enforce_style):
}
result = create_project_with_basic_checks(copie, extra_answers)

# black would still run successfully.
assert black_runs_successfully(result)


@pytest.mark.parametrize(
"notification",
Expand All @@ -211,7 +210,6 @@ def test_smoke_test_notification(copie, notification):

# run copier to hydrate a temporary project
result = create_project_with_basic_checks(copie, extra_answers)
assert black_runs_successfully(result)


@pytest.mark.parametrize(
Expand All @@ -233,8 +231,6 @@ def test_license(copie, license):
# run copier to hydrate a temporary project
result = create_project_with_basic_checks(copie, extra_answers)

assert black_runs_successfully(result)


@pytest.mark.parametrize(
"doc_answers",
Expand All @@ -255,7 +251,6 @@ def test_doc_combinations(copie, doc_answers):
# run copier to hydrate a temporary project
result = create_project_with_basic_checks(copie, doc_answers)

assert black_runs_successfully(result)
assert docs_build_successfully(result)
assert (result.project_dir / "docs").is_dir()

Expand All @@ -279,7 +274,6 @@ def test_doc_combinations_no_docs(copie, doc_answers):
# run copier to hydrate a temporary project
result = create_project_with_basic_checks(copie, doc_answers)

assert black_runs_successfully(result)
assert not (result.project_dir / "docs").is_dir()


Expand All @@ -296,8 +290,6 @@ def test_test_lowest_version(copie, test_lowest_version):
# run copier to hydrate a temporary project
result = create_project_with_basic_checks(copie, extra_answers)

assert black_runs_successfully(result)


def test_github_workflows_schema(copie):
"""Confirm the current GitHub workflows have valid schemas."""
Expand Down