@@ -633,8 +633,9 @@ def test_add_to_new_group_keeps_existing_group(
633633 ]
634634
635635
636+ @pytest .mark .parametrize ("additional_poetry_group" , [False , True ])
636637def test_add_to_existing_group (
637- app : PoetryTestApplication , tester : CommandTester
638+ app : PoetryTestApplication , tester : CommandTester , additional_poetry_group : bool
638639) -> None :
639640 pyproject : dict [str , Any ] = app .poetry .file .read ()
640641 groups_content : dict [str , Any ] = tomlkit .parse (
@@ -646,6 +647,16 @@ def test_add_to_existing_group(
646647"""
647648 )
648649 pyproject ["dependency-groups" ] = groups_content ["dependency-groups" ]
650+ if additional_poetry_group :
651+ poetry_groups_content : dict [str , Any ] = tomlkit .parse (
652+ """\
653+ [tool.poetry.group.example.dependencies]
654+ cachy = { allow-prereleases = true }
655+ """
656+ )
657+ pyproject ["tool" ]["poetry" ]["group" ] = poetry_groups_content ["tool" ]["poetry" ][
658+ "group"
659+ ]
649660 pyproject = cast ("TOMLDocument" , pyproject )
650661 app .poetry .file .write (pyproject )
651662
@@ -666,6 +677,13 @@ def test_add_to_existing_group(
666677 "cachy (>=0.2.0,<0.3.0)" ,
667678 "pendulum (>=1.4.4,<2.0.0)" ,
668679 ]
680+ if additional_poetry_group :
681+ assert "example" in pyproject ["tool" ]["poetry" ]["group" ]
682+ assert pyproject ["tool" ]["poetry" ]["group" ]["example" ]["dependencies" ] == {
683+ "cachy" : {"allow-prereleases" : True },
684+ }
685+ else :
686+ assert "group" not in pyproject ["tool" ]["poetry" ]
669687
670688
671689def test_add_to_group_with_latest_overwrite_existing (
@@ -757,6 +775,7 @@ def test_add_to_group_uses_existing_legacy_group(
757775
758776 pyproject = app .poetry .file .read ()
759777 pyproject = cast ("dict[str, Any]" , pyproject )
778+ assert "dependency-groups" not in pyproject
760779 assert "example" in pyproject ["tool" ]["poetry" ]["group" ]
761780 assert "pendulum" in pyproject ["tool" ]["poetry" ]["group" ]["example" ]["dependencies" ]
762781 assert "cachy" in pyproject ["tool" ]["poetry" ]["group" ]["example" ]["dependencies" ]
0 commit comments