Exemple #1
0
def tests_compiler(session: nox.Session, version: str) -> None:
    """Run the test with a specifiv GCC version."""
    session.install(
        "jinja2",
        "lxml",
        "pygments==2.7.4",
        "pytest",
        "pytest-timeout",
        "cmake",
        "yaxmldiff",
    )
    if platform.system() == "Windows":
        session.install("pywin32")
    coverage_args = []
    if os.environ.get("USE_COVERAGE") == "true":
        session.install("pytest-cov")
        coverage_args = ["--cov=gcovr", "--cov-branch"]
    session.install("-e", ".")
    set_environment(session, version)
    session.log("Print tool versions")
    session.run("python", "--version")
    # Use full path to executable
    session.env["CC"] = shutil.which(session.env["CC"]).replace(
        os.path.sep, "/")
    session.run(session.env["CC"], "--version", external=True)
    session.env["CXX"] = shutil.which(session.env["CXX"]).replace(
        os.path.sep, "/")
    session.run(session.env["CXX"], "--version", external=True)
    session.env["GCOV"] = shutil.which(session.env["CC"].replace(
        "clang", "llvm-cov").replace("gcc", "gcov")).replace(os.path.sep, "/")
    session.run(session.env["GCOV"], "--version", external=True)
    if "llvm-cov" in session.env["GCOV"]:
        session.env["GCOV"] += " gcov"

    session.chdir("gcovr/tests")
    session.run("make", "--silent", "clean", external=True)
    session.chdir("../..")
    args = ["-m", "pytest"]
    args += coverage_args
    args += session.posargs
    # For docker tests
    if "NOX_POSARGS" in os.environ:
        args += shlex.split(os.environ["NOX_POSARGS"])
    if "--" not in args:
        args += ["--"] + DEFAULT_TEST_DIRECTORIES
    session.run("python", *args)
Exemple #2
0
def lint(session: nox.Session):
    session.install("pytest", "hypothesis", "pytz", "black", "mypy", "isort")
    session.run("isort", "--check", "--diff", "iso8601")
    session.run("black", "--check", "--diff", "iso8601")
    session.run("mypy", "--strict", "iso8601")
def make_pickle(session: nox.Session) -> None:
    """
    Make a pickle file for this version
    """
    session.install(".[dev]")
    session.run("python", "tests/pickles/make_pickle.py", *session.posargs)
Exemple #4
0
def test(session: nox.Session):
    session.install(SETUPTOOLS_RUST, "pytest")
    session.install("--no-build-isolation", ".")
    session.run("pytest", *session.posargs)
Exemple #5
0
def docs(session: nox.Session):
    session.install(".", "Sphinx")
    session.run("sphinx-build", "docs", "docs/_build")
Exemple #6
0
def lint(session: nox.Session) -> None:
    """
    Lint the codebase (except for clang-format/tidy).
    """
    session.install("pre-commit")
    session.run("pre-commit", "run", "-a")
Exemple #7
0
def pre_commit(session: nox.Session):
    """
    Run pre-commit on all files.
    """
    session.run("pre-commit", "run", "--files", "noxfile.py", external=True)
Exemple #8
0
def lint(session: nox.Session) -> None:
    """
    Run linters on the codebase.
    """
    session.install("pre-commit")
    session.run("pre-commit", "run", "--all-files")
Exemple #9
0
def update_constraints(session: nox.Session) -> None:
    """
    Update the dependencies inplace.
    """
    session.install("requests", "pip-tools")
    session.run("python", "bin/update_dependencies.py")
Exemple #10
0
def _test_dist(session: nox.Session, path: str, pattern: str) -> None:
    (dist_path,) = Path(path).glob(pattern)
    session.install(f"{str(dist_path)}[test]")
    session.run("pytest", "tests/unit")
Exemple #11
0
def develop(session: nox.Session) -> None:
    session.run("python", "-m", "pip", "install", "--upgrade", "pip", "setuptools")
    session.install("-e", ".[develop]")
Exemple #12
0
def mypy(session: Session) -> None:
    """Type-check using mypy."""
    install_extras(session, extra="all")
    args = session.posargs or SOURCE_PATHS
    session.run("mypy", "--follow-imports=silent", *args, silent=True)
Exemple #13
0
def _generate_pip_deps_from_conda(session: Session,
                                  compare: bool = False) -> None:
    args = ["scripts/generate_pip_deps_from_conda.py"]
    if compare:
        args.append("--compare")
    session.run("python", *args)
Exemple #14
0
def upload_wheel(session: nox.Session) -> None:
    """Upload the wheel."""
    session.install("twine")
    session.run("twine", "upload", "dist/*", external=True)
Exemple #15
0
def tests_impl(
    session: nox.Session,
    extras: str = "socks,secure,brotli",
    byte_string_comparisons: bool = True,
) -> None:
    # Install deps and the package itself.
    session.install("-r", "dev-requirements.txt")
    session.install(f".[{extras}]")

    # Show the pip version.
    session.run("pip", "--version")
    # Print the Python version and bytesize.
    session.run("python", "--version")
    session.run("python", "-c",
                "import struct; print(struct.calcsize('P') * 8)")
    # Print OpenSSL information.
    session.run("python", "-m", "OpenSSL.debug")

    # Inspired from https://github.com/pyca/cryptography
    # We use parallel mode and then combine here so that coverage.py will take
    # the paths like .tox/pyXY/lib/pythonX.Y/site-packages/urllib3/__init__.py
    # and collapse them into src/urllib3/__init__.py.

    session.run(
        "python",
        *(("-bb", ) if byte_string_comparisons else ()),
        "-m",
        "coverage",
        "run",
        "--parallel-mode",
        "-m",
        "pytest",
        "-r",
        "a",
        "--tb=native",
        "--no-success-flaky-report",
        *(session.posargs or ("test/", )),
        env={"PYTHONWARNINGS": "always::DeprecationWarning"},
    )
    session.run("coverage", "combine")
    session.run("coverage", "report", "-m")
    session.run("coverage", "xml")
Exemple #16
0
def tests(session: Session):
    """Run unit tests."""
    session.install("-e", ".", *PYTEST_PACKAGES)
    session.run("pytest")
Exemple #17
0
def git_clone(session: nox.Session, git_url: str) -> None:
    session.run("git", "clone", "--depth", "1", git_url, external=True)
Exemple #18
0
def black(session: Session):
    """Check black formatting."""
    session.install("black")
    session.run("black", "--check", *LINT_PATHS)
Exemple #19
0
def make_changelog(session: nox.Session) -> None:
    """
    Inspect the closed issues and make entries for a changelog.
    """
    session.install("ghapi", "rich")
    session.run("python", "tools/make_changelog.py")
Exemple #20
0
def isort(session: Session):
    """Check imports sorting"""
    session.install("isort")
    session.run("isort", "--check", *LINT_PATHS)
Exemple #21
0
def test(session: nox.Session):
    session.install(SETUPTOOLS_RUST, "pytest", "pytest-benchmark", "beautifulsoup4")
    session.install("--no-build-isolation", ".")
    session.run("pytest", *session.posargs)
Exemple #22
0
def mypy(session: Session):
    """Run Mypy"""
    session.install("mypy", "types-PyYAML")
    session.run("mypy", *LINT_PATHS)
Exemple #23
0
def check_example(session: nox.Session):
    session.install(".", "mypy")
    session.run("mypy", "--strict", "docs/example.py")
    session.run("python", "docs/example.py")
Exemple #24
0
def pylint(session: Session):
    """Run pylint"""
    session.install("pylint", "-e", ".", *PYTEST_PACKAGES)
    session.run("pylint", "--rcfile=pyproject.toml", *LINT_PATHS)
Exemple #25
0
def test(session: nox.Session):
    session.install(".")
    session.install("pytest", "hypothesis", "pytz")
    session.run("pytest", "-vv", "--tb=short", "--log-level=INFO")
Exemple #26
0
def tests(session: nox.Session) -> None:
    """
    Run the unit and regular tests.
    """
    session.install(".[test]")
    session.run("pytest", *session.posargs)
Exemple #27
0
def lint(session: nox.Session) -> None:
    """
    Run the linter.
    """
    session.install("pre-commit")
    session.run("pre-commit", "run", "--all-files", *session.posargs)
Exemple #28
0
def lint(session: nox.Session) -> None:
    session.install("pre-commit")
    session.run("pre-commit", "run", "--all-files")

    mypy(session)
Exemple #29
0
def tests(session: nox.Session):
    session.install("-e", ".[tests]")
    session.run("pytest", "-ra", "tests")
Exemple #30
0
def format(session: nox.Session) -> None:
    session.install("black", "isort")
    session.run("isort", ".")
    session.run("black", ".")