@@ -197,3 +197,61 @@ def test_install_pylock_only_binary_ignored_for_archives(
197197 )
198198 assert "experimental" in result .stderr
199199 assert "Would install simple2-3.0" in result .stdout
200+
201+
202+ def test_install_pylock_default_prerelease (
203+ script : PipTestEnvironment ,
204+ shared_data : TestData ,
205+ ) -> None :
206+ """Prereleases are allowed by default."""
207+ pylock_path = shared_data .lockfiles .joinpath ("pylock.prerelease-wheel.toml" )
208+ result = script .pip (
209+ "install" ,
210+ "--no-index" ,
211+ "--dry-run" ,
212+ "-r" ,
213+ pylock_path ,
214+ allow_stderr_warning = True ,
215+ )
216+ assert "experimental" in result .stderr
217+ assert "Would install pkg-prerelease-1.0a1" in result .stdout
218+
219+
220+ def test_install_pylock_reject_prerelease (
221+ script : PipTestEnvironment ,
222+ shared_data : TestData ,
223+ ) -> None :
224+ """Prereleases are rejected when --only-final is set."""
225+ pylock_path = shared_data .lockfiles .joinpath ("pylock.prerelease-wheel.toml" )
226+ result = script .pip (
227+ "install" ,
228+ "--no-index" ,
229+ "--dry-run" ,
230+ "-r" ,
231+ pylock_path ,
232+ "--only-final=pkg-prerelease" ,
233+ expect_error = True ,
234+ )
235+ assert (
236+ "Only final releases are allowed for package 'pkg-prerelease' "
237+ "but it is pinned to a prerelease version 1.0a1" in result .stderr
238+ )
239+
240+
241+ def test_install_pylock_allow_archive_prerelease (
242+ script : PipTestEnvironment ,
243+ shared_data : TestData ,
244+ ) -> None :
245+ """--only-final does not influence direct URL requirements."""
246+ pylock_path = shared_data .lockfiles .joinpath ("pylock.prerelease-archive.toml" )
247+ result = script .pip (
248+ "install" ,
249+ "--no-index" ,
250+ "--dry-run" ,
251+ "-r" ,
252+ pylock_path ,
253+ "--only-final=pkg-prerelease" ,
254+ allow_stderr_warning = True ,
255+ )
256+ assert "experimental" in result .stderr
257+ assert "Would install pkg-prerelease-1.0a1" in result .stdout
0 commit comments