Ejemplo n.º 1
0
def test_from_empty_lines():
  reqs = requirements_from_lines([])
  assert len(reqs) == 0

  reqs = requirements_from_lines(dedent("""
  # comment
  """).splitlines())
  assert len(reqs) == 0
Ejemplo n.º 2
0
def test_allow_prereleases():
  # Prereleases should be disallowed by default.
  reqs = requirements_from_lines(dedent("""
  simple_requirement
  specific_requirement==2
  """).splitlines())
  assert not reqs[0].options._allow_prereleases
  assert not reqs[1].options._allow_prereleases

  reqs = requirements_from_lines(dedent("""
  --pre
  simple_requirement
  specific_requirement==2
  """).splitlines())
  assert reqs[0].options._allow_prereleases
  assert reqs[1].options._allow_prereleases
Ejemplo n.º 3
0
def test_all_external():
  reqs = requirements_from_lines(dedent("""
  simple_requirement
  specific_requirement==2
  --allow-all-external
  """).splitlines())
  assert reqs[0].options._allow_external
  assert reqs[1].options._allow_external
Ejemplo n.º 4
0
def test_index_types():
    reqs = requirements_from_lines(
        dedent(
            """
  simple_requirement
  --no-index
  """
        ).splitlines()
    )
    assert reqs[0].options._fetchers == []

    for prefix in ("-f ", "--find-links ", "--find-links="):
        reqs = requirements_from_lines(
            dedent(
                """
    foo
    --no-index
    %shttps://example.com/repo
    """
                % prefix
            ).splitlines()
        )
        assert len(reqs[0].options._fetchers) == 1
        assert reqs[0].options._fetchers[0].urls("foo") == ["https://example.com/repo"]

    for prefix in ("-i ", "--index-url ", "--index-url=", "--extra-index-url ", "--extra-index-url="):
        reqs = requirements_from_lines(
            dedent(
                """
    foo
    --no-index
    %shttps://example.com/repo/
    """
                % prefix
            ).splitlines()
        )
        assert len(reqs[0].options._fetchers) == 1, "Prefix is: %r" % prefix
        assert reqs[0].options._fetchers[0].urls("foo") == ["https://example.com/repo/foo/"]
Ejemplo n.º 5
0
def test_index_types():
  reqs = requirements_from_lines(dedent("""
  simple_requirement
  --no-index
  """).splitlines())
  assert reqs[0].options._fetchers == []

  for prefix in ('-f ', '--find-links ', '--find-links='):
    reqs = requirements_from_lines(dedent("""
    foo
    --no-index
    %shttps://example.com/repo
    """ % prefix).splitlines())
    assert len(reqs[0].options._fetchers) == 1
    assert reqs[0].options._fetchers[0].urls('foo') == ['https://example.com/repo']

  for prefix in ('-i ', '--index-url ', '--index-url=', '--extra-index-url ', '--extra-index-url='):
    reqs = requirements_from_lines(dedent("""
    foo
    --no-index
    %shttps://example.com/repo/
    """ % prefix).splitlines())
    assert len(reqs[0].options._fetchers) == 1, 'Prefix is: %r' % prefix
    assert reqs[0].options._fetchers[0].urls('foo') == ['https://example.com/repo/foo/']
Ejemplo n.º 6
0
def test_line_types(flag_separator):
  reqs = requirements_from_lines(dedent("""
  simple_requirement
  specific_requirement==2
  --allow-external%sspecific_requirement
  """ % flag_separator).splitlines())

  # simple_requirement
  assert len(reqs) == 2
  assert isinstance(reqs[0], ResolvableRequirement)
  assert reqs[0].requirement == Requirement.parse('simple_requirement')
  assert not reqs[0].options._allow_external

  # specific_requirement
  assert isinstance(reqs[1], ResolvableRequirement)
  assert reqs[1].requirement == Requirement.parse('specific_requirement==2')
  assert reqs[1].options._allow_external