Skip to content

Commit e0e95c8

Browse files
committed
add test
1 parent 4971716 commit e0e95c8

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tests/console/commands/test_add.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -992,13 +992,17 @@ def test_add_constraint_not_found_with_source(
992992
assert str(e.value) == "Could not find a matching version of package cachy"
993993

994994

995+
@pytest.mark.parametrize("group_name", ["dev", "foo.BAR"])
995996
def test_add_to_section_that_does_not_exist_yet(
996-
app: PoetryTestApplication, repo: TestRepository, tester: CommandTester
997+
app: PoetryTestApplication,
998+
repo: TestRepository,
999+
tester: CommandTester,
1000+
group_name: str,
9971001
) -> None:
9981002
repo.add_package(get_package("cachy", "0.1.0"))
9991003
repo.add_package(get_package("cachy", "0.2.0"))
10001004

1001-
tester.execute("cachy --group dev")
1005+
tester.execute(f"cachy --group {group_name}")
10021006

10031007
expected = """\
10041008
Using version ^0.2.0 for cachy
@@ -1020,12 +1024,13 @@ def test_add_to_section_that_does_not_exist_yet(
10201024
pyproject: dict[str, Any] = app.poetry.file.read()
10211025
content = pyproject["tool"]["poetry"]
10221026

1023-
assert "cachy" in content["group"]["dev"]["dependencies"]
1024-
assert content["group"]["dev"]["dependencies"]["cachy"] == "^0.2.0"
1027+
assert "cachy" in content["group"][group_name]["dependencies"]
1028+
assert content["group"][group_name]["dependencies"]["cachy"] == "^0.2.0"
10251029

1026-
expected = """\
1030+
escaped_group_name = f'"{group_name}"' if "." in group_name else group_name
1031+
expected = f"""\
10271032
1028-
[tool.poetry.group.dev.dependencies]
1033+
[tool.poetry.group.{escaped_group_name}.dependencies]
10291034
cachy = "^0.2.0"
10301035
10311036
"""

0 commit comments

Comments
 (0)