Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah Denbraver committed May 7, 2024
1 parent f83bd91 commit 84fda5b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
TEST_DATA_PATH = os.path.join(os.path.dirname(__file__), "test_data")
MINIMAL_WHEELS_PATH = os.path.join(TEST_DATA_PATH, "minimal_wheels")
PACKAGES_PATH = os.path.join(TEST_DATA_PATH, "packages")
PACKAGES_RELATIVE_PATH = os.path.relpath(
PACKAGES_PATH, os.path.commonpath([os.getcwd(), PACKAGES_PATH])
)
31 changes: 31 additions & 0 deletions tests/test_pip_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import annotations

import os
import tempfile

import pytest

from piptools._compat.pip_compat import parse_requirements
from piptools.repositories import PyPIRepository

from .constants import PACKAGES_RELATIVE_PATH


@pytest.fixture
def repository():
with tempfile.TemporaryDirectory() as cache_dir:
yield PyPIRepository([], cache_dir=cache_dir)


def test_parse_requirements_preserve_editable_relative(repository):
test_package_path = os.path.join(PACKAGES_RELATIVE_PATH, "small_fake_a")

with tempfile.NamedTemporaryFile("w") as infile:
infile.write(f"-e {test_package_path}")
infile.flush()
[install_requirement] = parse_requirements(
infile.name, session=repository.session
)

assert install_requirement.link.url == test_package_path
assert install_requirement.link.file_path == test_package_path

0 comments on commit 84fda5b

Please sign in to comment.