Skip to content

Commit 395b360

Browse files
committed
Add more comprehensive tests
1 parent 690250e commit 395b360

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/test_utilities.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,26 @@ def test_cycle(self) -> None:
358358
list(topological_sort(specs))
359359
self.assertEqual(cm.exception.code, 1)
360360
mock_error.assert_called_once_with("%s", "Dependency cycle detected: A -> B -> C -> D -> A")
361+
362+
def test_empty_set(self) -> None:
363+
"""Test that an empty set of packages is handled correctly."""
364+
self.assertEqual([], list(topological_sort({})))
365+
366+
def test_single_package(self) -> None:
367+
"""Test that a single package with no dependencies is handled correctly."""
368+
self.assertEqual(["A"], list(topological_sort({
369+
"A": {"package": "A", "requires": []}
370+
})))
371+
372+
def test_independent_packages(self) -> None:
373+
"""Test that packages with no dependencies between them are handled correctly."""
374+
result = list(topological_sort({
375+
"A": {"package": "A", "requires": []},
376+
"B": {"package": "B", "requires": []},
377+
"C": {"package": "C", "requires": []}
378+
}))
379+
self.assertEqual(set(["A", "B", "C"]), set(result))
380+
self.assertEqual(3, len(result))
381+
361382
if __name__ == '__main__':
362-
unittest.main()
383+
unittest.main()

0 commit comments

Comments
 (0)