@@ -93,6 +93,75 @@ def test_requirements_file(script: PipTestEnvironment) -> None:
93
93
assert result .files_created [script .site_packages / fn ].dir
94
94
95
95
96
+ @pytest .mark .network
97
+ def test_dependency_group (script : PipTestEnvironment ) -> None :
98
+ """
99
+ Test installing from a dependency group.
100
+
101
+ """
102
+ pyproject = script .scratch_path / "pyproject.toml"
103
+ pyproject .write_text (
104
+ textwrap .dedent (
105
+ """\
106
+ [dependency-groups]
107
+ initools = [
108
+ "INITools==0.2",
109
+ "peppercorn<=0.6",
110
+ ]
111
+ """
112
+ )
113
+ )
114
+ result = script .pip ("install" , "--group" , "initools" )
115
+ result .did_create (script .site_packages / "INITools-0.2.dist-info" )
116
+ result .did_create (script .site_packages / "initools" )
117
+ assert result .files_created [script .site_packages / "peppercorn" ].dir
118
+ assert result .files_created [script .site_packages / "peppercorn-0.6.dist-info" ].dir
119
+
120
+
121
+ @pytest .mark .network
122
+ def test_multiple_dependency_groups (script : PipTestEnvironment ) -> None :
123
+ """
124
+ Test installing from two dependency groups simultaneously.
125
+
126
+ """
127
+ pyproject = script .scratch_path / "pyproject.toml"
128
+ pyproject .write_text (
129
+ textwrap .dedent (
130
+ """\
131
+ [dependency-groups]
132
+ initools = ["INITools==0.2"]
133
+ peppercorn = ["peppercorn<=0.6"]
134
+ """
135
+ )
136
+ )
137
+ result = script .pip ("install" , "--group" , "initools" , "--group" , "peppercorn" )
138
+ result .did_create (script .site_packages / "INITools-0.2.dist-info" )
139
+ result .did_create (script .site_packages / "initools" )
140
+ assert result .files_created [script .site_packages / "peppercorn" ].dir
141
+ assert result .files_created [script .site_packages / "peppercorn-0.6.dist-info" ].dir
142
+
143
+
144
+ @pytest .mark .network
145
+ def test_dependency_group_with_non_normalized_name (script : PipTestEnvironment ) -> None :
146
+ """
147
+ Test installing from a dependency group with a non-normalized name, verifying that
148
+ the pyproject.toml content and CLI arg are normalized to match.
149
+
150
+ """
151
+ pyproject = script .scratch_path / "pyproject.toml"
152
+ pyproject .write_text (
153
+ textwrap .dedent (
154
+ """\
155
+ [dependency-groups]
156
+ INITOOLS = ["INITools==0.2"]
157
+ """
158
+ )
159
+ )
160
+ result = script .pip ("install" , "--group" , "IniTools" )
161
+ result .did_create (script .site_packages / "INITools-0.2.dist-info" )
162
+ result .did_create (script .site_packages / "initools" )
163
+
164
+
96
165
def test_schema_check_in_requirements_file (script : PipTestEnvironment ) -> None :
97
166
"""
98
167
Test installing from a requirements file with an invalid vcs schema..
@@ -212,6 +281,32 @@ def test_package_in_constraints_and_dependencies(
212
281
assert "installed TopoRequires-0.0.1" in result .stdout
213
282
214
283
284
+ def test_constraints_apply_to_dependency_groups (
285
+ script : PipTestEnvironment , data : TestData
286
+ ) -> None :
287
+ script .scratch_path .joinpath ("constraints.txt" ).write_text ("TopoRequires==0.0.1" )
288
+ pyproject = script .scratch_path / "pyproject.toml"
289
+ pyproject .write_text (
290
+ textwrap .dedent (
291
+ """\
292
+ [dependency-groups]
293
+ mylibs = ["TopoRequires2"]
294
+ """
295
+ )
296
+ )
297
+ result = script .pip (
298
+ "install" ,
299
+ "--no-index" ,
300
+ "-f" ,
301
+ data .find_links ,
302
+ "-c" ,
303
+ script .scratch_path / "constraints.txt" ,
304
+ "--group" ,
305
+ "mylibs" ,
306
+ )
307
+ assert "installed TopoRequires-0.0.1" in result .stdout
308
+
309
+
215
310
def test_multiple_constraints_files (script : PipTestEnvironment , data : TestData ) -> None :
216
311
script .scratch_path .joinpath ("outer.txt" ).write_text ("-c inner.txt" )
217
312
script .scratch_path .joinpath ("inner.txt" ).write_text ("Upper==1.0" )
0 commit comments