Skip to content

Commit 48ae7d0

Browse files
Add tests for pyproject.toml Python version selection
- Add test cases for PEP 621 requires-python field - Add test for Poetry python dependency - Verify that lowest compatible Python version is selected - All tests pass confirming current behavior is correct Co-authored-by: AbhishekBhaskar <22154418+AbhishekBhaskar@users.noreply.github.com>
1 parent 67cc816 commit 48ae7d0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

python/spec/dependabot/python/file_parser/python_requirement_parser_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,50 @@
6767
end
6868
end
6969

70+
context "with a pyproject.toml file" do
71+
let(:files) { [pyproject_file] }
72+
let(:pyproject_file) do
73+
Dependabot::DependencyFile.new(
74+
name: "pyproject.toml",
75+
content: pyproject_content
76+
)
77+
end
78+
79+
context "with PEP 621 requires-python" do
80+
let(:pyproject_content) do
81+
<<~TOML
82+
[project]
83+
name = "test-package"
84+
requires-python = ">= 3.9, <3.13"
85+
TOML
86+
end
87+
88+
it { is_expected.to eq([">= 3.9, <3.13"]) }
89+
end
90+
91+
context "with Poetry python dependency" do
92+
let(:pyproject_content) do
93+
<<~TOML
94+
[tool.poetry.dependencies]
95+
python = "^3.10"
96+
TOML
97+
end
98+
99+
it { is_expected.to eq(["^3.10"]) }
100+
end
101+
102+
context "without python version specified" do
103+
let(:pyproject_content) do
104+
<<~TOML
105+
[project]
106+
name = "test-package"
107+
TOML
108+
end
109+
110+
it { is_expected.to eq([]) }
111+
end
112+
end
113+
70114
context "with a setup.py file" do
71115
let(:files) { [setup_py] }
72116
let(:setup_py) do

0 commit comments

Comments
 (0)