Пример #1
0
def test_dump():
    converter = PoetryConverter()
    resolver = converter.load_resolver(
        Path('tests') / 'requirements' / 'poetry.toml')
    reqs = Requirement.from_graph(graph=resolver.graph, lock=False)
    assert len(reqs) > 2
    content = converter.dumps(reqs=reqs, project=resolver.graph.metainfo)
    assert 'requests = ' in content
    assert 'extras = ["security"]' in content
    assert 'toml = "==0.*,>=0.9.0"' in content

    assert 'https://github.com/django/django.git' in content

    parsed = tomlkit.parse(content)['tool']['poetry']
    assert '>=0.9' in parsed['dependencies']['toml']
    assert '>=2.13' in parsed['dependencies']['requests']['version']
    assert {'security'} == set(parsed['dependencies']['requests']['extras'])

    assert parsed['dependencies']['pathlib2']['allows-prereleases'] is True
    assert parsed['dependencies']['pathlib2']['python'] == '==2.7.*,>=2.7.0'

    assert parsed['dependencies']['django'][
        'git'] == 'https://github.com/django/django.git'
    assert parsed['dependencies']['django']['rev'] == '1.11.4'

    assert 'pytest' in parsed['dev-dependencies']
Пример #2
0
def test_entrypoints():
    converter = PoetryConverter()
    root = converter.load(Path('tests') / 'requirements' / 'poetry.toml')
    assert len(root.entrypoints) == 2

    content = converter.dumps(reqs=[], project=root)
    parsed = tomlkit.parse(content)['tool']['poetry']
    assert parsed['scripts']['my-script'] == 'my_package:main'
    assert dict(parsed['plugins']['flake8.extension']) == {
        'T00': 'flake8-todos.checker:Checker'
    }
Пример #3
0
def test_preserve_repositories():
    content = dedent("""
        [tool.poetry]
        name = "test"
        version = "1.2.3"

        [tool.poetry.dependencies]
        python = "*"

        [[tool.poetry.source]]
        name = "pypi"
        url = "https://pypi.org/pypi"
    """)
    converter = PoetryConverter()
    root = converter.loads(content)
    new_content = converter.dumps(reqs=[], project=root)
    parsed = tomlkit.parse(content)['tool']['poetry']
    new_parsed = tomlkit.parse(new_content)['tool']['poetry']
    assert parsed['source'] == new_parsed['source']
    assert parsed == new_parsed
Пример #4
0
def test_preserve_reqs_format(req, temp_path: Path):
    content = dedent("""
        [tool.poetry]
        name = "test"
        version = "1.2.3"

        [tool.poetry.dependencies]
        python = "*"
        {req}
    """).format(req=req)

    converter = PoetryConverter(project_path=temp_path)
    resolver = converter.loads_resolver(content)
    reqs = Requirement.from_graph(graph=resolver.graph, lock=False)
    new_content = converter.dumps(
        reqs=reqs,
        project=resolver.graph.metainfo,
        content=content,
    )
    assert content == new_content