diff --git a/README.md b/README.md index 84215fb..e1e755a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Python template with some awesome tools to quickstart a Python project with the industry best practices. It includes automatic generation of API documentation, tests using PyTest, code coverage, -ruff linting to enforce standardized Python coding and formatting, virtual environments using UV, workflow automation using Taskipy and a space optimized Dockerfile to kickstart your project and run tests using the power of Docker containers. +ruff linting to enforce standardized Python coding and formatting, virtual environments using uv, workflow automation using Taskipy and a space optimized Dockerfile to kickstart your project and run tests using the power of Docker containers. You only need to install [Cookiecutter](https://cookiecutter.readthedocs.io/en/1.7.2/usage.html)! @@ -90,12 +90,13 @@ This Project depends on the following projects. cookiecutter https://github.com/nullhack/python-project-template # move into your newly created project folder ``` -2. Install UV and Taskipy +2. Install uv and Taskipy ```sh - pip install --user --upgrade uv taskipy + pip install --user --upgrade uv ``` 3. Let Taskipy do it's magic ```sh + uv venv uv pip install .[dev] uv task test uv task run diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index cd993e7..36bfc4f 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -113,7 +113,8 @@ Some useful examples of how this project can be used: * Install requirements ```sh - uv run task '.[dev]' + uv venv + uv pip install '.[dev]' ``` * Run tests @@ -123,7 +124,7 @@ Some useful examples of how this project can be used: * Run the project ```sh - uv run main.py + uv run task run ``` * Generate API documentation diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 5af9d23..d36a6a2 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -76,17 +76,23 @@ pydocstyle.convention = "google" [tool.pytest.ini_options] minversion = "6.0" +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "unit", + "integration", + "system", + "acceptance", + "regression", + "smoke", + "sanity", + "performance", + "security", + "performance", +] addopts = """ --maxfail=1 \ --color=yes \ ---cov={{cookiecutter.package_name}} \ ---html=docs/pytest_report.html \ ---self-contained-html \ ---cov-fail-under={{cookiecutter.minimum_coverage}} \ ---cov-report term-missing \ ---cov-report html:docs/cov-report \ ---doctest-modules \ ---cov-config=pyproject.toml""" +""" testpaths = [ "tests", "{{cookiecutter.package_name}}" @@ -110,7 +116,22 @@ exclude_lines = [ [tool.taskipy.tasks] run = "python -m {{cookiecutter.package_name}}.{{cookiecutter.module_name}}" -test = "pytest" +test-report = """\ +pytest \ + --cov-config=pyproject.toml \ + --doctest-modules \ + --cov-fail-under=90 \ + --cov-report=term-missing \ + --cov-report=html:docs/cov-report \ + --html=docs/pytest_report.html \ + --self-contained-html\ +""" +test = """\ +python -c "import subprocess, sys; print('Running Smoke Tests...'); sys.exit(0 if subprocess.run(['pytest', '-m', 'smoke']).returncode in (0,5) else 1)" && \ +python -c "import subprocess, sys; print('Running Unit Tests...'); sys.exit(0 if subprocess.run(['pytest', '-m', 'unit']).returncode in (0,5) else 1)" && \ +python -c "print('Running Tests...');" && \ +task test-report\ +""" ruff-check = "ruff check **/*.py --fix" ruff-format = "ruff format **/*.py" lint = "task ruff-check && task ruff-format"