Skip to content

Commit 65e28ca

Browse files
committed
Add a uv remove test where a dependency is repeated
1 parent 4b0a4da commit 65e28ca

File tree

1 file changed

+139
-1
lines changed

1 file changed

+139
-1
lines changed

crates/uv/tests/it/edit.rs

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use assert_cmd::assert::OutputAssertExt;
33
use assert_fs::prelude::*;
4-
use indoc::indoc;
4+
use indoc::{formatdoc, indoc};
55
use insta::assert_snapshot;
66
use std::path::Path;
77

@@ -4385,6 +4385,144 @@ fn add_script_without_metadata_table_with_docstring() -> Result<()> {
43854385
Ok(())
43864386
}
43874387

4388+
/// Remove a dependency that is present in multiple places.
4389+
#[test]
4390+
fn remove_repeated() -> Result<()> {
4391+
let context = TestContext::new("3.12");
4392+
4393+
let anyio_local = context.workspace_root.join("scripts/packages/anyio_local");
4394+
4395+
let pyproject_toml = context.temp_dir.child("pyproject.toml");
4396+
pyproject_toml.write_str(&formatdoc! {r#"
4397+
[project]
4398+
name = "project"
4399+
version = "0.1.0"
4400+
requires-python = ">=3.12"
4401+
dependencies = ["anyio"]
4402+
4403+
[project.optional-dependencies]
4404+
foo = ["anyio"]
4405+
4406+
[tool.uv]
4407+
dev-dependencies = ["anyio"]
4408+
4409+
[tool.uv.sources]
4410+
anyio = {{ path = "{anyio_local}" }}
4411+
"#,
4412+
anyio_local = anyio_local.portable_display(),
4413+
})?;
4414+
4415+
uv_snapshot!(context.filters(), context.remove().arg("anyio"), @r###"
4416+
success: true
4417+
exit_code: 0
4418+
----- stdout -----
4419+
4420+
----- stderr -----
4421+
Resolved 4 packages in [TIME]
4422+
Prepared 3 packages in [TIME]
4423+
Installed 3 packages in [TIME]
4424+
+ anyio==4.3.0
4425+
+ idna==3.6
4426+
+ sniffio==1.3.1
4427+
"###);
4428+
4429+
let pyproject_toml = context.read("pyproject.toml");
4430+
4431+
insta::with_settings!({
4432+
filters => context.filters(),
4433+
}, {
4434+
assert_snapshot!(
4435+
pyproject_toml, @r###"
4436+
[project]
4437+
name = "project"
4438+
version = "0.1.0"
4439+
requires-python = ">=3.12"
4440+
dependencies = []
4441+
4442+
[project.optional-dependencies]
4443+
foo = ["anyio"]
4444+
4445+
[tool.uv]
4446+
dev-dependencies = ["anyio"]
4447+
4448+
[tool.uv.sources]
4449+
"###
4450+
);
4451+
});
4452+
4453+
uv_snapshot!(context.filters(), context.remove().arg("anyio").arg("--optional").arg("foo"), @r###"
4454+
success: true
4455+
exit_code: 0
4456+
----- stdout -----
4457+
4458+
----- stderr -----
4459+
Resolved 4 packages in [TIME]
4460+
Audited 3 packages in [TIME]
4461+
"###);
4462+
4463+
let pyproject_toml = context.read("pyproject.toml");
4464+
4465+
insta::with_settings!({
4466+
filters => context.filters(),
4467+
}, {
4468+
assert_snapshot!(
4469+
pyproject_toml, @r###"
4470+
[project]
4471+
name = "project"
4472+
version = "0.1.0"
4473+
requires-python = ">=3.12"
4474+
dependencies = []
4475+
4476+
[project.optional-dependencies]
4477+
foo = []
4478+
4479+
[tool.uv]
4480+
dev-dependencies = ["anyio"]
4481+
4482+
[tool.uv.sources]
4483+
"###
4484+
);
4485+
});
4486+
4487+
uv_snapshot!(context.filters(), context.remove().arg("anyio").arg("--dev"), @r###"
4488+
success: true
4489+
exit_code: 0
4490+
----- stdout -----
4491+
4492+
----- stderr -----
4493+
Resolved 1 package in [TIME]
4494+
Uninstalled 3 packages in [TIME]
4495+
- anyio==4.3.0
4496+
- idna==3.6
4497+
- sniffio==1.3.1
4498+
"###);
4499+
4500+
let pyproject_toml = context.read("pyproject.toml");
4501+
4502+
insta::with_settings!({
4503+
filters => context.filters(),
4504+
}, {
4505+
assert_snapshot!(
4506+
pyproject_toml, @r###"
4507+
[project]
4508+
name = "project"
4509+
version = "0.1.0"
4510+
requires-python = ">=3.12"
4511+
dependencies = []
4512+
4513+
[project.optional-dependencies]
4514+
foo = []
4515+
4516+
[tool.uv]
4517+
dev-dependencies = []
4518+
4519+
[tool.uv.sources]
4520+
"###
4521+
);
4522+
});
4523+
Ok(())
4524+
}
4525+
43884526
/// Remove from a PEP732 script,
43894527
#[test]
43904528
fn remove_script() -> Result<()> {

0 commit comments

Comments
 (0)