示例#1
0
def test_requires_with_non_exists_package(fixture, pypi_json):
    responses.add(
        responses.GET,
        f"https://pypi.org/pypi/djangodjango/json",
        body="",
        status=404,
        content_type="text/html",
    )
    requires = RequirementsTxt(
        fixture.with_name("non_exists_requirements.txt"))
    with pytest.raises(requests.exceptions.HTTPError):
        requires.packages
示例#2
0
def test_various_symbols_with_versions(fixture):
    pipfile = RequirementsTxt(fixture.with_name("various_symbols.txt"))
    assert [str(p) for p in pipfile.all_packages] == [
        "nose",
        "nose-cov",
        "beautifulsoup4",
        "docopt",
        "keyring",
        "coverage",
        "mopidy-dirble",
        "rejected",
        "green",
    ]
示例#3
0
def test_requires(fixture, pypi_json):
    requires = RequirementsTxt(fixture.with_name("requirements.txt"))
    for p in requires.all_packages:
        with open(pypi_json.with_name(f"{p.name}.json")) as f:
            responses.add(
                responses.GET,
                f"https://pypi.org/pypi/{p.name}/json",
                body=f.read(),
                status=200,
                content_type="application/json",
            )
    assert requires.path.name == "requirements.txt"
    assert requires.packages == ["adb-shell", "django", "pytest"]
    assert requires.dev_packages == []
示例#4
0
def test_requirements_if_not_exists():
    with pytest.raises(FileNotFoundError):
        RequirementsTxt(Path("./bar"))