Exemple #1
0
def chdir(session: Session, dir_path: Path) -> Iterator[Path]:
    """Temporarily chdir when entering CM and chdir back on exit."""
    orig_dir = Path.cwd()

    session.chdir(str(dir_path))
    try:
        yield dir_path
    finally:
        session.chdir(str(orig_dir))
Exemple #2
0
def workdir(
    nox_session: Session,
    dir_path: pathlib.Path,
) -> Iterator[pathlib.Path]:
    """Temporarily chdir when entering CM and chdir back on exit."""
    orig_dir = pathlib.Path.cwd()

    nox_session.chdir(dir_path)
    try:
        yield dir_path
    finally:
        nox_session.chdir(orig_dir)
Exemple #3
0
def workdir(
    nox_session: Session,
    dir_path: pathlib.Path,
) -> Iterator[pathlib.Path]:
    """Temporarily chdir when entering CM and chdir back on exit."""
    orig_dir = pathlib.Path.cwd()

    # https://github.com/theacodes/nox/pull/376
    nox_session.chdir(dir_path)  # type: ignore
    try:
        yield dir_path
    finally:
        nox_session.chdir(orig_dir)  # type: ignore
Exemple #4
0
def format(session: Session) -> None:
    """Auto format Python and Javascript code"""
    # format Python
    install_requirements_file(session, "check-style")
    session.run("black", ".")
    session.run("isort", ".")

    # format client Javascript
    session.chdir(SRC / "client")
    session.run("npm", "run", "format", external=True)

    # format docs Javascript
    session.chdir(ROOT / "docs" / "source" / "_custom_js")
    session.run("npm", "run", "format", external=True)
Exemple #5
0
def example_run(session: Session, name: str = None):
    descr = get_example_descr(name)

    install_dependencies(session, descr.get("requires", []))
    show_environment_info(session)

    session.log("Running example %r", descr.get("name"))
    session.chdir(str(descr["dir"].absolute()))
    result = session.run(*descr["command"], silent=True)

    output = get_contents(Path(descr["dir"], descr["output"]))

    if result != output:
        session.error(
            "Example output did not match expected output:\n"
            "===== EXPECTED OUTPUT BEGIN =====\n%s\n"
            "===== EXPECTED OUTPUT END =====\n"
            "===== ACTUAL OUTPUT BEGIN =====\n%s\n"
            "===== ACTUAL OUTPUT END =====\n",
            output,
            result,
        )
    session.log("Example output matched expected output, all is well.")
Exemple #6
0
def test_contracts(session: Session) -> None:
    session.install("-r", "requirements.txt")
    install_ganache(session)
    session.chdir("contracts")
    session.run("brownie", "compile")
    session.run("brownie", "test")
Exemple #7
0
def build_js(session: Session) -> None:
    """Build javascript client code"""
    session.chdir(SRC / "client")
    session.run("npm", "run", "build", external=True)
Exemple #8
0
def setup_client_env(session: Session) -> None:
    session.chdir(SRC / "client")
    session.run("npm", "install", external=True)