{% extends "_base.py.j2" %}

{% block content %}

import os

import nox  # type: ignore


# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
# Add tests for Python 3.15 alpha1
# https://peps.python.org/pep-0790/
ALL_PYTHON = [
    "3.9",
    "3.10",
    "3.11",
    "3.12",
    "3.13",
    "3.14",
]

@nox.session(python=ALL_PYTHON)
def unit(session):
    """Run the unit test suite."""

    session.install('coverage', 'pytest', 'pytest-cov')
    session.install('-e', '.')

    session.run(
        'py.test',
        '--quiet',
        '--cov={{ api.naming.module_namespace|join("/") }}/{{ api.naming.versioned_module_name }}/',
        '--cov=tests/',
        '--cov-config=.coveragerc',
        '--cov-report=term',
        '--cov-report=html',
        os.path.join('tests', 'unit', 'gapic', '{{ api.naming.versioned_module_name }}'),
    )


@nox.session(python=ALL_PYTHON)
def mypy(session):
    """Run the type checker."""
    session.install('mypy')
    session.install('.')
    session.run(
        'mypy',
        {% if api.naming.module_namespace %}
        '{{ api.naming.module_namespace[0] }}',
        {% else %}
        '{{ api.naming.versioned_module_name }}',
        {% endif %}
        "--check-untyped-defs",
        *session.posargs,
    )
{% endblock %}
