How to use the nox.manifest.Manifest 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_manifest.py View on Github external
def test_add_session_parametrized():
    manifest = Manifest({}, mock.sentinel.CONFIG)

    # Define a session with parameters.
    @nox.parametrize("param", ("a", "b", "c"))
    def my_session(session, param):
        pass

    my_session.python = None

    # Add the session to the manifest.
    for session in manifest.make_session("my_session", my_session):
        manifest.add_session(session)
    assert len(manifest) == 3
github theacodes / nox / tests / test_manifest.py View on Github external
def test_filter_by_keyword():
    sessions = create_mock_sessions()
    manifest = Manifest(sessions, mock.sentinel.CONFIG)
    assert len(manifest) == 2
    manifest.filter_by_keywords("foo or bar")
    assert len(manifest) == 2
    manifest.filter_by_keywords("foo")
    assert len(manifest) == 1
github theacodes / nox / tests / test_manifest.py View on Github external
def test_notify_noop():
    manifest = Manifest({}, mock.sentinel.CONFIG)

    # Define a session and add it to the manifest.
    def my_session(session):
        pass

    my_session.python = None

    for session in manifest.make_session("my_session", my_session):
        manifest.add_session(session)

    assert len(manifest) == 1

    # Establish idempotency; notifying a session already in the queue no-ops.
    manifest.notify("my_session")
    assert len(manifest) == 1
github theacodes / nox / tests / test_tasks.py View on Github external
def test_filter_manifest():
    config = _options.options.namespace(sessions=(), keywords=())
    manifest = Manifest({"foo": session_func, "bar": session_func}, config)
    return_value = tasks.filter_manifest(manifest, config)
    assert return_value is manifest
    assert len(manifest) == 2
github theacodes / nox / tests / test_tasks.py View on Github external
def test_run_manifest():
    # Set up a valid manifest.
    config = _options.options.namespace(stop_on_first_error=False)
    sessions_ = [
        mock.Mock(spec=sessions.SessionRunner),
        mock.Mock(spec=sessions.SessionRunner),
    ]
    manifest = Manifest({}, config)
    manifest._queue = copy.copy(sessions_)

    # Ensure each of the mocks returns a successful result
    for mock_session in sessions_:
        mock_session.execute.return_value = sessions.Result(
            session=mock_session, status=sessions.Status.SUCCESS
        )

    # Run the manifest.
    results = tasks.run_manifest(manifest, global_config=config)

    # Verify the results look correct.
    assert len(results) == 2
    assert results[0].session == sessions_[0]
    assert results[1].session == sessions_[1]
    for result in results:
github theacodes / nox / tests / test_manifest.py View on Github external
def test_filter_by_name_maintains_order():
    sessions = create_mock_sessions()
    manifest = Manifest(sessions, mock.sentinel.CONFIG)
    manifest.filter_by_name(("bar", "foo"))
    assert [session.name for session in manifest] == ["bar", "foo"]
github theacodes / nox / tests / test_manifest.py View on Github external
def test_len():
    sessions = create_mock_sessions()
    manifest = Manifest(sessions, mock.sentinel.CONFIG)
    assert len(manifest) == 2
    for session in manifest:
        assert len(manifest) == 2
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_tasks.py View on Github external
def test_filter_manifest_keywords():
    config = _options.options.namespace(sessions=(), keywords="foo or bar")
    manifest = Manifest(
        {"foo": session_func, "bar": session_func, "baz": session_func}, config
    )
    return_value = tasks.filter_manifest(manifest, config)
    assert return_value is manifest
    assert len(manifest) == 2