Ejemplo n.º 1
0
def test_resolvable_package():
    builder = ResolverOptionsBuilder()
    source_name = 'foo-2.3.4.tar.gz'
    pkg = SourcePackage.from_href(source_name)
    resolvable = ResolvablePackage.from_string(source_name, builder)
    assert resolvable.packages() == [pkg]

    mock_iterator = mock.create_autospec(Iterator, spec_set=True)
    mock_iterator.iter.return_value = iter([])
    # fetchers are currently unused for static packages.
    assert resolvable.compatible(mock_iterator) == []
    assert mock_iterator.iter.mock_calls == []
    assert resolvable.name == 'foo'
    assert resolvable.exact is True
    assert resolvable.extras() == []

    resolvable = ResolvablePackage.from_string(source_name + '[extra1,extra2]',
                                               builder)
    assert resolvable.extras() == ['extra1', 'extra2']

    assert Resolvable.get('foo-2.3.4.tar.gz') == ResolvablePackage.from_string(
        'foo-2.3.4.tar.gz', builder)

    with pytest.raises(ResolvablePackage.InvalidRequirement):
        ResolvablePackage.from_string('foo', builder)
Ejemplo n.º 2
0
def test_resolvable_package():
  builder = ResolverOptionsBuilder()
  source_name = 'foo-2.3.4.tar.gz'
  pkg = SourcePackage.from_href(source_name)
  resolvable = ResolvablePackage.from_string(source_name, builder)
  assert resolvable.packages() == [pkg]

  mock_iterator = mock.create_autospec(Iterator, spec_set=True)
  mock_iterator.iter.return_value = iter([])
  # fetchers are currently unused for static packages.
  assert resolvable.compatible(mock_iterator) == []
  assert mock_iterator.iter.mock_calls == []
  assert resolvable.name == 'foo'
  assert resolvable.exact is True
  assert resolvable.extras() == []

  resolvable = ResolvablePackage.from_string(source_name + '[extra1,extra2]', builder)
  assert resolvable.extras() == ['extra1', 'extra2']

  assert Resolvable.get('foo-2.3.4.tar.gz') == ResolvablePackage.from_string(
      'foo-2.3.4.tar.gz', builder)

  with pytest.raises(ResolvablePackage.InvalidRequirement):
    ResolvablePackage.from_string('foo', builder)
Ejemplo n.º 3
0
def test_resolvables_from_iterable():
  builder = ResolverOptionsBuilder()

  reqs = [
      'foo',  # string
      Package.from_href('foo-2.3.4.tar.gz'),  # Package
      pkg_resources.Requirement.parse('foo==2.3.4'),
  ]

  resolved_reqs = list(resolvables_from_iterable(reqs, builder))

  assert resolved_reqs == [
      ResolvableRequirement.from_string('foo', builder),
      ResolvablePackage.from_string('foo-2.3.4.tar.gz', builder),
      ResolvableRequirement.from_string('foo==2.3.4', builder),
  ]
Ejemplo n.º 4
0
def test_resolvables_from_iterable():
    builder = ResolverOptionsBuilder()

    reqs = [
        'foo',  # string
        Package.from_href('foo-2.3.4.tar.gz'),  # Package
        pkg_resources.Requirement.parse('foo==2.3.4'),
    ]

    resolved_reqs = list(resolvables_from_iterable(reqs, builder))

    assert resolved_reqs == [
        ResolvableRequirement.from_string('foo', builder),
        ResolvablePackage.from_string('foo-2.3.4.tar.gz', builder),
        ResolvableRequirement.from_string('foo==2.3.4', builder),
    ]