예제 #1
0
def test_find_best_match_preserves_period():
    fallback_repo = mock.create_autospec(PyPIRepository)
    pin = ireq('foo.bar==42.0')
    existing_pins = {key_from_ireq(pin): pin}
    repo = LocalRequirementsRepository(existing_pins, fallback_repo)
    result = repo.find_best_match(ireq('foo.bar'))
    assert repr(result) == repr(ireq('foo.bar==42.0'))
예제 #2
0
def test_find_best_match(existing_pin, to_find, pin_matches, pinned_extras,
                         requested_extras):
    fallback_repo = mock.create_autospec(PyPIRepository)
    fallback_repo.find_best_match.return_value = 'fallback_result'
    pin = ireq(existing_pin, pinned_extras) if existing_pin else None
    existing_pins = {key_from_ireq(pin): pin} if pin else {}
    repo = LocalRequirementsRepository(existing_pins, fallback_repo)
    ireq_to_find = ireq(to_find, requested_extras)
    result = repo.find_best_match(ireq_to_find)
    if pin_matches:
        assert repr(result) == repr(ireq(existing_pin, requested_extras))
    else:
        fallback_repo.find_best_match.assert_called_with(ireq_to_find, None)
        assert result == 'fallback_result'