Skip to content

Commit 6da4003

Browse files
committed
One more test
1 parent 5f35380 commit 6da4003

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

crates/uv/tests/it/edit.rs

+67
Original file line numberDiff line numberDiff line change
@@ -6335,3 +6335,70 @@ fn add_preserves_end_of_line_comments() -> Result<()> {
63356335
});
63366336
Ok(())
63376337
}
6338+
6339+
#[test]
6340+
fn add_preserves_open_bracket_comment() -> Result<()> {
6341+
let context = TestContext::new("3.12");
6342+
6343+
let pyproject_toml = context.temp_dir.child("pyproject.toml");
6344+
pyproject_toml.write_str(indoc! {r#"
6345+
[project]
6346+
name = "project"
6347+
version = "0.1.0"
6348+
requires-python = ">=3.12"
6349+
dependencies = [ # comment 0
6350+
# comment 1
6351+
"anyio==3.7.0", # comment 2
6352+
# comment 3
6353+
]
6354+
6355+
[build-system]
6356+
requires = ["setuptools>=42"]
6357+
build-backend = "setuptools.build_meta"
6358+
"#})?;
6359+
6360+
uv_snapshot!(context.filters(), context.add().arg("requests==2.31.0"), @r###"
6361+
success: true
6362+
exit_code: 0
6363+
----- stdout -----
6364+
6365+
----- stderr -----
6366+
Resolved 8 packages in [TIME]
6367+
Prepared 8 packages in [TIME]
6368+
Installed 8 packages in [TIME]
6369+
+ anyio==3.7.0
6370+
+ certifi==2024.2.2
6371+
+ charset-normalizer==3.3.2
6372+
+ idna==3.6
6373+
+ project==0.1.0 (from file://[TEMP_DIR]/)
6374+
+ requests==2.31.0
6375+
+ sniffio==1.3.1
6376+
+ urllib3==2.2.1
6377+
"###);
6378+
6379+
let pyproject_toml = context.read("pyproject.toml");
6380+
6381+
insta::with_settings!({
6382+
filters => context.filters(),
6383+
}, {
6384+
assert_snapshot!(
6385+
pyproject_toml, @r###"
6386+
[project]
6387+
name = "project"
6388+
version = "0.1.0"
6389+
requires-python = ">=3.12"
6390+
dependencies = [ # comment 0
6391+
# comment 1
6392+
"anyio==3.7.0", # comment 2
6393+
# comment 3
6394+
"requests==2.31.0",
6395+
]
6396+
6397+
[build-system]
6398+
requires = ["setuptools>=42"]
6399+
build-backend = "setuptools.build_meta"
6400+
"###
6401+
);
6402+
});
6403+
Ok(())
6404+
}

0 commit comments

Comments
 (0)