Skip to content

Commit

Permalink
tests: add circular check dependency test
Browse files Browse the repository at this point in the history
  • Loading branch information
layday committed Sep 2, 2022
1 parent 011e42f commit e80b433
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_projectbuilder.py
Expand Up @@ -45,6 +45,10 @@ def from_name(cls, name):
return RecursiveMockDistribution()
elif name == 'prerelease_dep':
return PrereleaseMockDistribution()
elif name == 'circular_dep':
return CircularMockDistribution()
elif name == 'nested_circular_dep':
return NestedCircularMockDistribution()
raise importlib_metadata.PackageNotFoundError


Expand Down Expand Up @@ -96,6 +100,28 @@ def read_text(self, filename):
""".strip()


class CircularMockDistribution(MockDistribution):
def read_text(self, filename):
if filename == 'METADATA':
return """
Metadata-Version: 2.2
Name: circular_dep
Version: 1.0.0
Requires-Dist: nested_circular_dep
""".strip()


class NestedCircularMockDistribution(MockDistribution):
def read_text(self, filename):
if filename == 'METADATA':
return """
Metadata-Version: 2.2
Name: nested_circular_dep
Version: 1.0.0
Requires-Dist: circular_dep
""".strip()


@pytest.mark.parametrize(
('requirement_string', 'expected'),
[
Expand Down Expand Up @@ -126,6 +152,7 @@ def read_text(self, filename):
('extras_dep[extra_without_associated_deps] == 1.0.0', None),
('extras_dep[extra_without_associated_deps] == 2.0.0', ('extras_dep[extra_without_associated_deps] == 2.0.0',)),
('prerelease_dep >= 1.0.0', None),
('circular_dep', None),
],
)
def test_check_dependency(monkeypatch, requirement_string, expected):
Expand Down

0 comments on commit e80b433

Please sign in to comment.