Skip to content

Commit f5ae2b3

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

File tree

1 file changed

+140
-1
lines changed

1 file changed

+140
-1
lines changed

crates/uv/tests/it/edit.rs

Lines changed: 140 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
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;
7+
use uv_fs::Simplified;
78

89
use uv_static::EnvVars;
910

@@ -4385,6 +4386,144 @@ fn add_script_without_metadata_table_with_docstring() -> Result<()> {
43854386
Ok(())
43864387
}
43874388

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

0 commit comments

Comments
 (0)