How to use the nox._options.options.namespace function in nox

To help you get started, we’ve selected a few nox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github theacodes / nox / tests / test_sessions.py View on Github external
def make_runner(self):
        func = mock.Mock()
        func.python = None
        func.venv_backend = None
        func.reuse_venv = False
        runner = nox.sessions.SessionRunner(
            name="test",
            signatures=["test(1, 2)"],
            func=func,
            global_config=_options.options.namespace(
                noxfile=os.path.join(os.getcwd(), "noxfile.py"),
                envdir="envdir",
                posargs=mock.sentinel.posargs,
                reuse_existing_virtualenvs=False,
                error_on_missing_interpreters=False,
            ),
            manifest=mock.create_autospec(nox.manifest.Manifest),
        )
        return runner
github theacodes / nox / tests / test_tasks.py View on Github external
def test_verify_manifest_nonempty():
    config = _options.options.namespace(sessions=(), keywords=())
    manifest = Manifest({"session": session_func}, config)
    return_value = tasks.verify_manifest_nonempty(manifest, global_config=config)
    assert return_value == manifest
github theacodes / nox / tests / test_sessions.py View on Github external
def make_session_and_runner(self):
        func = mock.Mock(spec=["python"], python="3.7")
        runner = nox.sessions.SessionRunner(
            name="test",
            signatures=["test"],
            func=func,
            global_config=_options.options.namespace(
                posargs=mock.sentinel.posargs,
                error_on_external_run=False,
                install_only=False,
            ),
            manifest=mock.create_autospec(nox.manifest.Manifest),
        )
        runner.venv = mock.create_autospec(nox.virtualenv.VirtualEnv)
        runner.venv.env = {}
        runner.venv.bin = "/no/bin/for/you"
        return nox.sessions.Session(runner=runner), runner
github theacodes / nox / tests / test_sessions.py View on Github external
def test_install_non_default_kwargs(self):
        runner = nox.sessions.SessionRunner(
            name="test",
            signatures=["test"],
            func=mock.sentinel.func,
            global_config=_options.options.namespace(posargs=mock.sentinel.posargs),
            manifest=mock.create_autospec(nox.manifest.Manifest),
        )
        runner.venv = mock.create_autospec(nox.virtualenv.VirtualEnv)
        runner.venv.env = {}

        class SessionNoSlots(nox.sessions.Session):
            pass

        session = SessionNoSlots(runner=runner)

        with mock.patch.object(session, "_run", autospec=True) as run:
            session.install("requests", "urllib3", silent=False)
            run.assert_called_once_with(
                "pip", "install", "requests", "urllib3", silent=False, external="error"
            )
github theacodes / nox / tests / test_tasks.py View on Github external
def test_verify_manifest_empty():
    config = _options.options.namespace(sessions=(), keywords=())
    manifest = Manifest({}, config)
    return_value = tasks.verify_manifest_nonempty(manifest, global_config=config)
    assert return_value == 3
github theacodes / nox / tests / test_tasks.py View on Github external
def test_honor_list_request(description):
    config = _options.options.namespace(
        list_sessions=True, noxfile="noxfile.py", color=False
    )
    manifest = mock.create_autospec(Manifest)
    manifest.list_all_sessions.return_value = [
        (argparse.Namespace(friendly_name="foo", description=description), True)
    ]
    return_value = tasks.honor_list_request(manifest, global_config=config)
    assert return_value == 0
github theacodes / nox / tests / test__option_set.py View on Github external
def test_session_completer(self):
        parsed_args = _options.options.namespace(sessions=(), keywords=())
        all_nox_sessions = _options._session_completer(
            prefix=None, parsed_args=parsed_args
        )
        # if noxfile.py changes, this will have to change as well since these are
        # some of the actual sessions found in noxfile.py
        some_expected_sessions = ["cover", "blacken", "lint", "docs"]
        assert len(set(some_expected_sessions) - set(all_nox_sessions)) == 0
github theacodes / nox / tests / test_tasks.py View on Github external
    @nox.session
    def bar():
        pass

    @nox.session(name="not-a-bar")
    def not_a_bar():
        pass

    def notasession():
        pass

    # Mock up a noxfile.py module and configuration.
    mock_module = argparse.Namespace(
        __name__=foo.__module__, foo=foo, bar=bar, notasession=notasession
    )
    config = _options.options.namespace(sessions=(), keywords=())

    # Get the manifest and establish that it looks like what we expect.
    manifest = tasks.discover_manifest(mock_module, config)
    sessions = list(manifest)
    assert [s.func for s in sessions] == [foo, bar, not_a_bar]
    assert [i.friendly_name for i in sessions] == ["foo", "bar", "not-a-bar"]
github theacodes / nox / tests / test_tasks.py View on Github external
def test_filter_manifest_not_found():
    config = _options.options.namespace(sessions=("baz",), keywords=())
    manifest = Manifest({"foo": session_func, "bar": session_func}, config)
    return_value = tasks.filter_manifest(manifest, config)
    assert return_value == 3