|
1 | 1 | #![cfg(all(feature = "python", feature = "pypi"))] |
2 | 2 |
|
3 | 3 | use anyhow::Result; |
| 4 | +use assert_cmd::assert::OutputAssertExt; |
4 | 5 | use assert_fs::prelude::*; |
5 | 6 | use indoc::{formatdoc, indoc}; |
6 | 7 | use insta::assert_snapshot; |
7 | 8 | use url::Url; |
8 | 9 |
|
| 10 | +use crate::common::packse_index_url; |
9 | 11 | use common::{uv_snapshot, TestContext}; |
10 | 12 |
|
11 | 13 | mod common; |
@@ -2208,10 +2210,6 @@ fn lock_upgrade_log_multi_version() -> Result<()> { |
2208 | 2210 | lock, @r###" |
2209 | 2211 | version = 1 |
2210 | 2212 | requires-python = ">=3.12" |
2211 | | - environment-markers = [ |
2212 | | - "sys_platform == 'win32'", |
2213 | | - "sys_platform != 'win32'", |
2214 | | - ] |
2215 | 2213 |
|
2216 | 2214 | [options] |
2217 | 2215 | exclude-newer = "2024-03-25 00:00:00 UTC" |
@@ -5804,3 +5802,42 @@ fn lock_upgrade_package() -> Result<()> { |
5804 | 5802 |
|
5805 | 5803 | Ok(()) |
5806 | 5804 | } |
| 5805 | + |
| 5806 | +/// Check that we discard the fork marker from the lockfile when using `--upgrade`. |
| 5807 | +#[test] |
| 5808 | +fn lock_upgrade_drop_fork_markers() -> Result<()> { |
| 5809 | + let context = TestContext::new("3.12"); |
| 5810 | + |
| 5811 | + let requirements = r#"[project] |
| 5812 | + name = "forking" |
| 5813 | + version = "0.1.0" |
| 5814 | + requires-python = ">=3.12" |
| 5815 | + dependencies = ["fork-upgrade-foo==1"] |
| 5816 | + "#; |
| 5817 | + |
| 5818 | + let pyproject_toml = context.temp_dir.child("pyproject.toml"); |
| 5819 | + pyproject_toml.write_str(requirements)?; |
| 5820 | + context |
| 5821 | + .lock() |
| 5822 | + .arg("--index-url") |
| 5823 | + .arg(packse_index_url()) |
| 5824 | + .env_remove("UV_EXCLUDE_NEWER") |
| 5825 | + .assert() |
| 5826 | + .success(); |
| 5827 | + let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap(); |
| 5828 | + assert!(lock.contains("environment-markers")); |
| 5829 | + |
| 5830 | + // Remove the bound and lock with `--upgrade`. |
| 5831 | + pyproject_toml.write_str(&requirements.replace("fork-upgrade-foo==1", "fork-upgrade-foo"))?; |
| 5832 | + context |
| 5833 | + .lock() |
| 5834 | + .arg("--index-url") |
| 5835 | + .arg(packse_index_url()) |
| 5836 | + .env_remove("UV_EXCLUDE_NEWER") |
| 5837 | + .arg("--upgrade") |
| 5838 | + .assert() |
| 5839 | + .success(); |
| 5840 | + let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap(); |
| 5841 | + assert!(!lock.contains("environment-markers")); |
| 5842 | + Ok(()) |
| 5843 | +} |
0 commit comments