예제 #1
0
파일: test_search.py 프로젝트: hrnciar/pip
def test_latest_prerelease_install_message(
        caplog: pytest.LogCaptureFixture,
        monkeypatch: pytest.MonkeyPatch) -> None:
    """
    Test documentation for installing pre-release packages is displayed
    """
    hits: List["TransformedHit"] = [{
        "name": "ni",
        "summary": "For knights who say Ni!",
        "versions": ["1.0.0", "1.0.1a"],
    }]

    installed_package = mock.Mock(project_name="ni")
    monkeypatch.setattr("pip._vendor.pkg_resources.working_set",
                        [installed_package])

    get_dist = mock.Mock()
    get_dist.return_value = mock.Mock(version="1.0.0")
    monkeypatch.setattr("pip._internal.commands.search.get_distribution",
                        get_dist)
    with caplog.at_level(logging.INFO):
        print_results(hits)

    message = caplog.records[-1].getMessage()
    assert 'pre-release; install with "pip install --pre"' in message
    assert get_dist.call_args_list == [mock.call("ni")]
예제 #2
0
파일: test_search.py 프로젝트: zapnat/pip
def test_search_print_results_should_contain_latest_versions(caplog):
    """
    Test that printed search results contain the latest package versions
    """
    hits = [{
        'name': 'testlib1',
        'summary': 'Test library 1.',
        'versions': ['1.0.5', '1.0.3']
    }, {
        'name': 'testlib2',
        'summary': 'Test library 1.',
        'versions': ['2.0.1', '2.0.3']
    }]
    print_results(hits)
    log_messages = sorted([r.getMessage() for r in caplog.records])
    assert log_messages[0].startswith('testlib1 (1.0.5)')
    assert log_messages[1].startswith('testlib2 (2.0.3)')
예제 #3
0
파일: test_search.py 프로젝트: edmorley/pip
def test_search_print_results_should_contain_latest_versions(caplog):
    """
    Test that printed search results contain the latest package versions
    """
    hits = [
        {
            'name': 'testlib1',
            'summary': 'Test library 1.',
            'versions': ['1.0.5', '1.0.3']
        },
        {
            'name': 'testlib2',
            'summary': 'Test library 1.',
            'versions': ['2.0.1', '2.0.3']
        }
    ]
    print_results(hits)
    log_messages = sorted([r.getMessage() for r in caplog.records])
    assert log_messages[0].startswith('testlib1 (1.0.5)')
    assert log_messages[1].startswith('testlib2 (2.0.3)')
예제 #4
0
def test_latest_prerelease_install_message(caplog, monkeypatch):
    """
    Test documentation for installing pre-release packages is displayed
    """
    hits = [{
        'name': 'ni',
        'summary': 'For knights who say Ni!',
        'versions': ['1.0.0', '1.0.1a']
    }]

    installed_package = pretend.stub(project_name="ni")
    monkeypatch.setattr("pip._vendor.pkg_resources.working_set",
                        [installed_package])

    dist = pretend.stub(version="1.0.0")
    get_dist = pretend.call_recorder(lambda x: dist)
    monkeypatch.setattr("pip._vendor.pkg_resources.get_distribution", get_dist)
    with caplog.at_level(logging.INFO):
        print_results(hits)

    message = caplog.records[-1].getMessage()
    assert 'pre-release; install with "pip install --pre"' in message
    assert get_dist.calls == [pretend.call('ni')]
예제 #5
0
def test_search_print_results_should_contain_latest_versions(caplog):
    """
    Test that printed search results contain the latest package versions
    """
    hits = [
        {
            "name": "testlib1",
            "summary": "Test library 1.",
            "versions": ["1.0.5", "1.0.3"],
        },
        {
            "name": "testlib2",
            "summary": "Test library 1.",
            "versions": ["2.0.1", "2.0.3"],
        },
    ]

    with caplog.at_level(logging.INFO):
        print_results(hits)

    log_messages = sorted([r.getMessage() for r in caplog.records])
    assert log_messages[0].startswith("testlib1 (1.0.5)")
    assert log_messages[1].startswith("testlib2 (2.0.3)")