File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
src/poetry/console/commands Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,9 @@ def handle(self) -> int:
122
122
# dictionary.
123
123
content : dict [str , Any ] = self .poetry .file .read ()
124
124
poetry_content = content ["tool" ]["poetry" ]
125
- project_name = canonicalize_name (poetry_content ["name" ])
125
+ project_name = (
126
+ canonicalize_name (name ) if (name := poetry_content .get ("name" )) else None
127
+ )
126
128
127
129
if group == MAIN_GROUP :
128
130
if "dependencies" not in poetry_content :
Original file line number Diff line number Diff line change @@ -101,6 +101,29 @@ def test_add_no_constraint(
101
101
assert content ["dependencies" ]["cachy" ] == "^0.2.0"
102
102
103
103
104
+ def test_add_non_package_mode_no_name (
105
+ repo : TestRepository ,
106
+ project_factory : ProjectFactory ,
107
+ command_tester_factory : CommandTesterFactory ,
108
+ ) -> None :
109
+ repo .add_package (get_package ("cachy" , "0.2.0" ))
110
+
111
+ poetry = project_factory (
112
+ name = "foobar" , pyproject_content = "[tool.poetry]\n package-mode = false\n "
113
+ )
114
+ tester = command_tester_factory ("add" , poetry = poetry )
115
+ tester .execute ("cachy" )
116
+
117
+ assert isinstance (tester .command , InstallerCommand )
118
+ assert tester .command .installer .executor .installations_count == 1
119
+
120
+ pyproject : dict [str , Any ] = poetry .file .read ()
121
+ content = pyproject ["tool" ]["poetry" ]
122
+
123
+ assert "cachy" in content ["dependencies" ]
124
+ assert content ["dependencies" ]["cachy" ] == "^0.2.0"
125
+
126
+
104
127
def test_add_replace_by_constraint (
105
128
app : PoetryTestApplication , repo : TestRepository , tester : CommandTester
106
129
) -> None :
You can’t perform that action at this time.
0 commit comments