Python nox.session() Examples

The following are 30 code examples of nox.session(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module nox , or try the search function .
Example #1
Source File: nox.py    From gax-python with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def lint(session):
    session.interpreter = 'python3.6'
    session.install(
        'flake8', 'flake8-import-order', 'pylint', 'docutils',
        'gcp-devrel-py-tools>=0.0.3')
    session.install('.')
    session.run(
        'python', 'setup.py', 'check', '--metadata',
        '--restructuredtext', '--strict')
    session.run(
        'flake8',
        '--import-order-style=google',
        '--application-import-names=google,tests',
        '--ignore=E501,I202',
        '--exclude=gapic,fixtures',
        'google', 'tests')
    session.run(
        'gcp-devrel-py-tools', 'run-pylint',
        '--config', 'pylint.conf.py',
        '--library-filesets', 'google',
        '--test-filesets', 'tests',
        success_codes=range(0, 31)) 
Example #2
Source File: noxfile.py    From python-ndb with Apache License 2.0 6 votes vote down vote up
def doctest(session):
    # Install all dependencies.
    session.install("Sphinx")
    session.install("sphinxcontrib.spelling")
    session.install(".")
    # Run the script for building docs and running doctests.
    run_args = [
        "sphinx-build",
        "-W",
        "-b",
        "doctest",
        "-d",
        get_path("docs", "_build", "doctrees"),
        get_path("docs"),
        get_path("docs", "_build", "doctest"),
    ]
    session.run(*run_args) 
Example #3
Source File: noxfile.py    From python-firestore with Apache License 2.0 6 votes vote down vote up
def default(session):
    # Install all test dependencies, then install this package in-place.
    session.install("mock", "pytest", "pytest-cov")
    session.install("-e", ".")

    # Run py.test against the unit tests.
    session.run(
        "py.test",
        "--quiet",
        "--cov=google.cloud.firestore",
        "--cov=google.cloud",
        "--cov=tests.unit",
        "--cov-append",
        "--cov-config=.coveragerc",
        "--cov-report=",
        "--cov-fail-under=0",
        os.path.join("tests", "unit"),
        *session.posargs,
    ) 
Example #4
Source File: noxfile.py    From python-firestore with Apache License 2.0 6 votes vote down vote up
def docs(session):
    """Build the docs for this library."""

    session.install("-e", ".")
    session.install("sphinx<3.0.0", "alabaster", "recommonmark")

    shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
    session.run(
        "sphinx-build",
        "-W",  # warnings as errors
        "-T",  # show full traceback on exception
        "-N",  # no colors
        "-b",
        "html",
        "-d",
        os.path.join("docs", "_build", "doctrees", ""),
        os.path.join("docs", ""),
        os.path.join("docs", "_build", "html", ""),
    ) 
Example #5
Source File: noxfile.py    From python-ndb with Apache License 2.0 6 votes vote down vote up
def run_black(session, use_check=False):
    args = ["black"]
    if use_check:
        args.append("--check")

    args.extend(
        [
            "--line-length=79",
            get_path("docs"),
            get_path("noxfile.py"),
            get_path("google"),
            get_path("tests"),
        ]
    )

    session.run(*args) 
Example #6
Source File: noxfile.py    From python-ndb with Apache License 2.0 5 votes vote down vote up
def unit(session):
    # Install all dependencies.
    session.install("pytest", "pytest-cov")
    session.install("mock")
    session.install(".")
    # THis variable is used to skip coverage by Python version
    session.env["PY_VERSION"] = session.python[0]
    # Run py.test against the unit tests.
    run_args = ["pytest"]
    if session.posargs:
        run_args.extend(session.posargs)
    else:
        run_args.extend(
            [
                "--cov=google.cloud.ndb",
                "--cov=unit",
                "--cov-config",
                get_path(".coveragerc"),
                "--cov-report=term-missing",
            ]
        )
    run_args.append(get_path("tests", "unit"))
    session.run(*run_args)

    # Do not run cover session for Python 2, or it will fail
    if not session.posargs and session.python[0] != "2":
        session.notify("cover") 
Example #7
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def default_cloud_sdk_authorized_user(session):
    configure_cloud_sdk(session, AUTHORIZED_USER_FILE)
    session.install(*TEST_DEPENDENCIES)
    session.install(LIBRARY_DIR)
    session.run("pytest", "test_default.py") 
Example #8
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def compute_engine(session):
    session.install(*TEST_DEPENDENCIES)
    # unset Application Default Credentials so
    # credentials are detected from environment
    del session.virtualenv.env["GOOGLE_APPLICATION_CREDENTIALS"]
    session.install(LIBRARY_DIR)
    session.run("pytest", "test_compute_engine.py") 
Example #9
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def default_cloud_sdk_service_account(session):
    configure_cloud_sdk(session, SERVICE_ACCOUNT_FILE)
    session.env[EXPECT_PROJECT_ENV] = "1"
    session.install(*TEST_DEPENDENCIES)
    session.install(LIBRARY_DIR)
    session.run("pytest", "test_default.py") 
Example #10
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def default_explicit_service_account(session):
    session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
    session.env[EXPECT_PROJECT_ENV] = "1"
    session.install(*TEST_DEPENDENCIES)
    session.install(LIBRARY_DIR)
    session.run("pytest", "test_default.py", "test_id_token.py") 
Example #11
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def oauth2_credentials(session):
    session.install(*TEST_DEPENDENCIES)
    session.install(LIBRARY_DIR)
    session.run("pytest", "test_oauth2_credentials.py") 
Example #12
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def service_account(session):
    session.install(*TEST_DEPENDENCIES)
    session.install(LIBRARY_DIR)
    session.run("pytest", "test_service_account.py") 
Example #13
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def configure_cloud_sdk(session, application_default_credentials, project=False):
    """Installs and configures the Cloud SDK with the given application default
    credentials.

    If project is True, then a project will be set in the active config.
    If it is false, this will ensure no project is set.
    """
    install_cloud_sdk(session)

    # Setup the service account as the default user account. This is
    # needed for the project ID detection to work. Note that this doesn't
    # change the application default credentials file, which is user
    # credentials instead of service account credentials sometimes.
    session.run(
        GCLOUD, "auth", "activate-service-account", "--key-file", SERVICE_ACCOUNT_FILE
    )

    if project:
        session.run(GCLOUD, "config", "set", "project", "example-project")
    else:
        session.run(GCLOUD, "config", "unset", "project")

    # Copy the credentials file to the config root. This is needed because
    # unfortunately gcloud doesn't provide a clean way to tell it to use
    # a particular set of credentials. However, this does verify that gcloud
    # also considers the credentials valid by calling application-default
    # print-access-token
    session.run(copy_credentials, application_default_credentials)

    # Calling this forces the Cloud SDK to read the credentials we just wrote
    # and obtain a new access token with those credentials. This validates
    # that our credentials matches the format expected by gcloud.
    # Silent is set to True to prevent leaking secrets in test logs.
    session.run(
        GCLOUD, "auth", "application-default", "print-access-token", silent=True
    )


# Test sesssions 
Example #14
Source File: noxfile.py    From google-auth-library-python with Apache License 2.0 5 votes vote down vote up
def default_explicit_authorized_user(session):
    session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE
    session.install(*TEST_DEPENDENCIES)
    session.install(LIBRARY_DIR)
    session.run("pytest", "test_default.py") 
Example #15
Source File: noxfile.py    From python-ndb with Apache License 2.0 5 votes vote down vote up
def lint(session):
    """Run linters.
    Returns a failure if the linters find linting errors or sufficiently
    serious code quality issues.
    """
    session.install("flake8", "black")
    run_black(session, use_check=True)
    session.run("flake8", "google", "tests") 
Example #16
Source File: noxfile.py    From python-ndb with Apache License 2.0 5 votes vote down vote up
def cover(session):
    # Install all dependencies.
    session.install("coverage")
    # THis variable is used to skip coverage by Python version
    session.env["PY_VERSION"] = session.python[0]
    # Run coverage report.
    session.run("coverage", "report", "--fail-under=100", "--show-missing")
    # Erase cached coverage data.
    session.run("coverage", "erase") 
Example #17
Source File: nox.py    From gax-python with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def cover(session):
    session.interpreter = 'python3.6'
    session.install('-r', 'test-requirements.txt')
    session.install('.')
    session.run(
        'py.test', '--cov=google.gax', '--cov=tests', '--cov-report=', 'tests')
    session.run(
        'coverage', 'report', '--show-missing', '--fail-under=98') 
Example #18
Source File: nox.py    From GPflowOpt with Apache License 2.0 5 votes vote down vote up
def cover(session):
    session.install('coverage', 'pytest-cov')
    session.run('coverage', 'report') 
Example #19
Source File: nox.py    From GPflowOpt with Apache License 2.0 5 votes vote down vote up
def system(session):
    session.install('pytest', 'pytest-cov', *(TEST_DEPS + SYSTEM_TEST_DEPS))
    session.install('-e', '.', '--process-dependency-links')

    # Run py.test against the unit tests.
    session.run(
        'py.test',
        '--cov-report=',
        '--cov-append',
        '--cov=gpflowopt',
        '--cov-config=.coveragerc',
        'testing/system'
    ) 
Example #20
Source File: nox.py    From GPflowOpt with Apache License 2.0 5 votes vote down vote up
def unit(session):
    session.install('pytest', 'pytest-cov', *TEST_DEPS)
    session.install('-e', '.', '--process-dependency-links')

    # Run py.test against the unit tests.
    session.run(
        'py.test',
        '--cov-report=',
        '--cov-append',
        '--cov=gpflowopt',
        '--color=yes',
        '--cov-config=.coveragerc',
        'testing/unit'
    ) 
Example #21
Source File: noxfile.py    From google-music-scripts with MIT License 5 votes vote down vote up
def doc(session):
	shutil.rmtree('docs/_build', ignore_errors=True)
	session.install('-U', '.[doc]')
	session.cd('docs')
	session.run(
		'sphinx-build',
		'-b',
		'html',
		'-W',
		'-d',
		'_build/doctrees',
		'.',
		'_build/html'
	) 
Example #22
Source File: noxfile.py    From google-music-scripts with MIT License 5 votes vote down vote up
def lint(session):
	session.install('-U', '.[lint]')
	session.run('flake8', 'src/') 
Example #23
Source File: noxfile.py    From assistant-sdk-python with Apache License 2.0 5 votes vote down vote up
def release(session):
    session.install('pip', 'setuptools', 'wheel')
    session.run('python', 'setup.py', 'sdist', 'bdist_wheel')
    session.run('python', 'setup.py', 'sdist', 'bdist_wheel') 
Example #24
Source File: noxfile.py    From assistant-sdk-python with Apache License 2.0 5 votes vote down vote up
def lint(session):
    session.install('pip', 'setuptools')
    session.install('docutils', 'flake8', 'readme_renderer')
    session.run('flake8', 'nox.py', 'setup.py')
    session.run('python', 'setup.py', 'check',
                '--restructuredtext', '--strict') 
Example #25
Source File: noxfile.py    From assistant-sdk-python with Apache License 2.0 5 votes vote down vote up
def release(session):
    session.install('pip', 'setuptools', 'wheel')
    session.run('python', 'setup.py', 'sdist', 'bdist_wheel') 
Example #26
Source File: noxfile.py    From assistant-sdk-python with Apache License 2.0 5 votes vote down vote up
def endtoend_test(session):
    session.install('pip', 'setuptools')
    session.install('pytest', 'future')
    session.install('../google-assistant-grpc/')
    session.install('-e', '.[samples]')
    session.run('py.test', '-k', 'test_endtoend', 'tests') 
Example #27
Source File: noxfile.py    From assistant-sdk-python with Apache License 2.0 5 votes vote down vote up
def unittest(session):
    session.install('pip', 'setuptools')
    session.install('pytest', 'future')
    session.install('../google-assistant-grpc/')
    session.install('-e', '.[samples]')
    session.run('py.test', '-k', 'not test_endtoend', 'tests') 
Example #28
Source File: noxfile.py    From assistant-sdk-python with Apache License 2.0 5 votes vote down vote up
def lint(session):
    session.install('pip', 'setuptools')
    session.install('docutils', 'flake8', 'readme_renderer')
    session.run('flake8',
                'googlesamples', 'tests',
                'nox.py', 'setup.py')
    session.run('python', 'setup.py', 'check',
                '--restructuredtext', '--strict')
    session.run('python', '-m', 'json.tool', 'actions.json') 
Example #29
Source File: nox.py    From gax-python with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def unit_tests(session, python):
    session.interpreter = python
    session.install('-r', 'test-requirements.txt')
    session.install('.')
    session.run(
        'py.test', '--cov=google.gax', '--cov=tests', 'tests',
        *session.posargs) 
Example #30
Source File: nox.py    From gax-python with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def docs(session):
    session.interpreter = 'python3.6'
    session.install('-r', 'docs/requirements-docs.txt')
    session.install('.')
    session.chdir('docs')
    session.run('make', 'html')