@@ -358,6 +358,44 @@ def test_remove_canonicalized_named_removes_dependency_correctly(
358
358
assert expected in string_content
359
359
360
360
361
+ def test_remove_package_does_not_exist (
362
+ tester : CommandTester ,
363
+ app : PoetryTestApplication ,
364
+ repo : TestRepository ,
365
+ command_tester_factory : CommandTesterFactory ,
366
+ ) -> None :
367
+ repo .add_package (Package ("foo" , "2.0.0" ))
368
+
369
+ original_content = app .poetry .file .read ().as_string ()
370
+
371
+ with pytest .raises (ValueError ) as e :
372
+ tester .execute ("foo" )
373
+
374
+ assert str (e .value ) == "The following packages were not found: foo"
375
+ assert app .poetry .file .read ().as_string () == original_content
376
+
377
+
378
+ def test_remove_package_no_dependencies (
379
+ tester : CommandTester ,
380
+ app : PoetryTestApplication ,
381
+ repo : TestRepository ,
382
+ command_tester_factory : CommandTesterFactory ,
383
+ ) -> None :
384
+ repo .add_package (Package ("foo" , "2.0.0" ))
385
+
386
+ pyproject : dict [str , Any ] = app .poetry .file .read ()
387
+ assert "dependencies" not in pyproject ["project" ]
388
+ del pyproject ["tool" ]["poetry" ]["dependencies" ]
389
+ pyproject = cast ("TOMLDocument" , pyproject )
390
+ app .poetry .file .write (pyproject )
391
+ app .poetry .package ._dependency_groups = {}
392
+
393
+ with pytest .raises (ValueError ) as e :
394
+ tester .execute ("foo" )
395
+
396
+ assert str (e .value ) == "The following packages were not found: foo"
397
+
398
+
361
399
def test_remove_command_should_not_write_changes_upon_installer_errors (
362
400
tester : CommandTester ,
363
401
app : PoetryTestApplication ,
0 commit comments