Skip to content

Commit

Permalink
Use RequirementsFileParserError instead of RecursionError
Browse files Browse the repository at this point in the history
  • Loading branch information
hellozee committed Aug 18, 2024
1 parent 15b3acb commit 7698545
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _parse_and_recurse(
if initial_file is not None
else ""
)
raise RecursionError(
raise RequirementsFileParseError(
f"{req_path} recursively references itself in {filename} {tail}"
)
# Keeping a track where was each file first included in
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import pytest

import pip._internal.exceptions
import pip._internal.req.req_file # this will be monkeypatched
from pip._internal.exceptions import InstallationError, RequirementsFileParseError
from pip._internal.index.package_finder import PackageFinder
Expand Down Expand Up @@ -364,7 +363,7 @@ def test_recursive_requirements_file(

# When the passed requirements file recursively references itself
with pytest.raises(
RecursionError,
RequirementsFileParseError,
match=(
f"{path_to_string(req_files[0])} recursively references itself"
f" in {path_to_string(req_files[req_file_count - 1])}"
Expand All @@ -378,7 +377,7 @@ def test_recursive_requirements_file(
f"-r {req_files[req_file_count - 2].name}"
)
with pytest.raises(
RecursionError,
RequirementsFileParseError,
match=(
f"{path_to_string(req_files[req_file_count - 2])} recursively"
" references itself in"
Expand All @@ -401,7 +400,7 @@ def test_recursive_relative_requirements_file(
level_2_req_file.write_text("-r ../../root.txt")

with pytest.raises(
RecursionError,
RequirementsFileParseError,
match=(
f"{path_to_string(root_req_file)} recursively references itself in"
f" {path_to_string(level_2_req_file)}"
Expand Down

0 comments on commit 7698545

Please sign in to comment.