def pytype(session: Session) -> None: """Run the static type checker using pytype.""" args = session.posargs or ["--disable=import-error", *locations] session.install("pytype") session.run("pytype", *args)
def cover(session) -> None: """Run tests and generate coverage reports in both terminal output and XML (for Codecov)""" session.run("pytest", *PYTEST_ARGS, *COVERAGE_ARGS)
def mypy(session: Session) -> None: """Type-check using mypy.""" pass args = session.posargs or locations session.install("mypy") session.run("mypy", *args)
def black(session): """Run black code formatter.""" args = session.posargs or locations session.install("black") session.run("black", *args)
def xdoctest(session: Session) -> None: """Run examples with xdoctest.""" args = session.posargs or ["all"] session.install(".") session.install("xdoctest[colors]") session.run("python", "-m", "xdoctest", package, *args)
def coverage(session): """Run tests and generate coverage report""" cmd = 'pytest -n auto --cov --cov-report=term --cov-report=html' session.run(*cmd.split(' '))
def lint(session): """Run linters and code formatters via pre-commit""" cmd = 'pre-commit run --all-files' session.run(*cmd.split(' '))
def coverage(session): """Run tests and generate coverage report""" cmd_1 = f'pytest {UNIT_TESTS} -rs {XDIST_ARGS} {COVERAGE_ARGS}' cmd_2 = f'pytest {INTEGRATION_TESTS} -rs {XDIST_ARGS} {COVERAGE_ARGS} --cov-append' session.run(*cmd_1.split(' ')) session.run(*cmd_2.split(' '))
def typeguard(session: Session) -> None: """Runtime type checking using Typeguard.""" session.install(".") session.install("typeguard", "pygments", *TEST_REQUIREMENTS) session.run("pytest", f"--typeguard-packages={package}", *session.posargs)
def test_main(session): session.poetry.installroot(distribution_format=SDIST) session.install('pytest') session.run(*args('pytest -v tests/main'))
def docs(session: Session) -> None: """Build the documentation.""" session.install(".") session.install("sphinx", "sphinx_autodoc_typehints") session.run("sphinx-build", "docs", "docs/_build")
def test_geo(session): session.poetry.installroot(distribution_format=SDIST) session.install('csv-reconcile-geo') session.install('pytest') session.run(*args('pytest -v tests/plugins/geo'))
def docs(session): """Build Sphinx documentation""" session.run("sphinx-build", "docs", "docs/_build/html", "-j", "auto")
def test(session) -> None: session.run("pytest", *PYTEST_ARGS)
def coverage(session: Session) -> None: """Upload coverage data.""" session.install("coverage[toml]", "codecov") session.run("coverage", "xml", "--fail-under=0") session.run("codecov", *session.posargs)
def tests(session): session.install("pytest", ".") session.run("pytest", *session.posargs)
def test(session): """Run tests for a specific python version""" test_paths = session.posargs or ['test'] session.install('.', 'pytest', 'pytest-sugar', 'pytest-xdist', 'requests-mock') session.run('pytest', '-n', 'auto', *test_paths)
def tests(session: Session) -> None: session.install(".") session.install("pytest", "coverage[toml]", "hypothesis", "pytest-cov") session.run("poetry", "install", external=True) session.run("pytest", "--cov")
def docs(session): """Build Sphinx documentation""" cmd = 'sphinx-build docs docs/_build/html -j auto' session.run(*cmd.split(' '))
def black(session: Session) -> None: args = session.posargs or locations session.install("black", "blackdoc") session.run("black", *args) session.run("blackdoc", *args)
def tests(session: Session) -> None: session.install(".") session.install("pytest") session.run("pytest")
def typeguard(session: Session) -> None: """Runtime type checking using Typeguard.""" session.install(".") session.install("pytest", "typeguard", "pygments", "aioresponses", "pytest-asyncio") session.run("pytest", f"--typeguard-packages={package}", *session.posargs)
def safety(session: Session) -> None: """Scan dependencies for insecure packages.""" requirements = session.poetry.export_requirements() session.install("safety") session.run("safety", "check", "--full-report", f"--file={requirements}")
def lint(session): session.run("black", ".", external=True) session.run("flake8", "./ioccheck", "./test", external=True) session.run("bandit", "-r", "./ioccheck", external=True) session.run("mypy", "--warn-unreachable", "./ioccheck", external=True) session.run("pylint", "./ioccheck", external=True) session.run("isort", ".", external=True)
def typeguard(session: Session) -> None: """Runtime type checking using Typeguard.""" session.install(".") session.install("pytest", "typeguard", "pygments", "requests-mock") session.run("pytest", f"--typeguard-packages={package}", *session.posargs)
def lint(session) -> None: session.run("pre-commit", "run", "--all-files")