@@ -103,6 +103,7 @@ def repo_add_default_packages(repo: TestRepository) -> None:
103103 repo .add_package (get_package ("tomlkit" , "0.5.5" ))
104104 repo .add_package (get_package ("pyyaml" , "3.13" ))
105105 repo .add_package (get_package ("pyyaml" , "4.2b2" ))
106+ repo .add_package (get_package ("torch" , "2.4.0+cpu" ))
106107
107108
108109def test_add_no_constraint (app : PoetryTestApplication , tester : CommandTester ) -> None :
@@ -133,6 +134,33 @@ def test_add_no_constraint(app: PoetryTestApplication, tester: CommandTester) ->
133134 assert content ["dependencies" ]["cachy" ] == "^0.2.0"
134135
135136
137+ def test_add_local_version (app : PoetryTestApplication , tester : CommandTester ) -> None :
138+ tester .execute ("torch" )
139+
140+ expected = """\
141+ Using version ^2.4.0 for torch
142+
143+ Updating dependencies
144+ Resolving dependencies...
145+
146+ Package operations: 1 install, 0 updates, 0 removals
147+
148+ - Installing torch (2.4.0+cpu)
149+
150+ Writing lock file
151+ """
152+
153+ assert tester .io .fetch_output () == expected
154+ assert isinstance (tester .command , InstallerCommand )
155+ assert tester .command .installer .executor .installations_count == 1
156+
157+ pyproject : dict [str , Any ] = app .poetry .file .read ()
158+ content = pyproject ["tool" ]["poetry" ]
159+
160+ assert "torch" in content ["dependencies" ]
161+ assert content ["dependencies" ]["torch" ] == "^2.4.0"
162+
163+
136164def test_add_non_package_mode_no_name (
137165 project_factory : ProjectFactory ,
138166 command_tester_factory : CommandTesterFactory ,
0 commit comments