2323
2424from poetry .factory import Factory
2525from poetry .installation import Installer
26- from poetry .installation .executor import Executor as BaseExecutor
2726from poetry .packages import Locker as BaseLocker
2827from poetry .repositories import Repository
2928from poetry .repositories import RepositoryPool
3231from poetry .utils .env import MockEnv
3332from poetry .utils .env import NullEnv
3433from tests .helpers import MOCK_DEFAULT_GIT_REVISION
34+ from tests .helpers import TestExecutor
3535from tests .helpers import get_dependency
3636from tests .helpers import get_package
3737
4242 from _pytest .fixtures import FixtureRequest
4343 from pytest_mock import MockerFixture
4444
45- from poetry .installation .operations .operation import Operation
4645 from poetry .repositories .legacy_repository import LegacyRepository
4746 from poetry .repositories .pypi_repository import PyPiRepository
4847 from poetry .utils .env import Env
4948 from tests .conftest import Config
5049 from tests .types import FixtureDirGetter
5150
5251
53- class Executor (BaseExecutor ):
54- def __init__ (self , * args : Any , ** kwargs : Any ) -> None :
55- super ().__init__ (* args , ** kwargs )
56-
57- self ._installs : list [Package ] = []
58- self ._updates : list [Package ] = []
59- self ._uninstalls : list [Package ] = []
60-
61- @property
62- def installations (self ) -> list [Package ]:
63- return self ._installs
64-
65- @property
66- def updates (self ) -> list [Package ]:
67- return self ._updates
68-
69- @property
70- def removals (self ) -> list [Package ]:
71- return self ._uninstalls
72-
73- def _do_execute_operation (self , operation : Operation ) -> int :
74- ret_val = super ()._do_execute_operation (operation )
75-
76- if not operation .skipped :
77- getattr (self , f"_{ operation .job_type } s" ).append (operation .package )
78-
79- return ret_val
80-
81- def _execute_install (self , operation : Operation ) -> int :
82- return 0
83-
84- def _execute_update (self , operation : Operation ) -> int :
85- return 0
86-
87- def _execute_uninstall (self , operation : Operation ) -> int :
88- return 0
89-
90-
9152class CustomInstalledRepository (InstalledRepository ):
9253 @classmethod
9354 def load (
@@ -207,7 +168,7 @@ def installer(
207168 pool ,
208169 config ,
209170 installed = installed ,
210- executor = Executor (env , pool , config , NullIO ()),
171+ executor = TestExecutor (env , pool , config , NullIO ()),
211172 )
212173
213174
@@ -760,7 +721,7 @@ def test_run_install_with_synchronization(
760721 * managed_reserved_package_names ,
761722 }
762723
763- assert isinstance (installer .executor , Executor )
724+ assert isinstance (installer .executor , TestExecutor )
764725 assert {r .name for r in installer .executor .removals } == expected_removals
765726
766727
@@ -963,7 +924,7 @@ def test_run_with_optional_and_python_restricted_dependencies(
963924 # We should only have 2 installs:
964925 # C,D since python version is not compatible
965926 # with B's python constraint and A is optional
966- assert isinstance (installer .executor , Executor )
927+ assert isinstance (installer .executor , TestExecutor )
967928 assert installer .executor .installations_count == 2
968929 assert installer .executor .installations [0 ].name == "d"
969930 assert installer .executor .installations [1 ].name == "c"
@@ -1011,7 +972,7 @@ def test_run_with_optional_and_platform_restricted_dependencies(
1011972 # We should only have 2 installs:
1012973 # C,D since the mocked python version is not compatible
1013974 # with B's python constraint and A is optional
1014- assert isinstance (installer .executor , Executor )
975+ assert isinstance (installer .executor , TestExecutor )
1015976 assert installer .executor .installations_count == 2
1016977 assert installer .executor .installations [0 ].name == "d"
1017978 assert installer .executor .installations [1 ].name == "c"
@@ -1182,7 +1143,7 @@ def test_run_with_conflicting_dependency_extras(
11821143 assert locker .written_data == expected
11831144
11841145 # Results of installation are consistent with the 'extra' input
1185- assert isinstance (installer .executor , Executor )
1146+ assert isinstance (installer .executor , TestExecutor )
11861147
11871148 expected_installations = []
11881149 if extra == "extra-one" :
@@ -1275,7 +1236,7 @@ def test_run_with_exclusive_extras_different_sources(
12751236 pool ,
12761237 config ,
12771238 installed = installed ,
1278- executor = Executor (
1239+ executor = TestExecutor (
12791240 MockEnv (),
12801241 pool ,
12811242 config ,
@@ -1291,7 +1252,7 @@ def test_run_with_exclusive_extras_different_sources(
12911252 if not locked :
12921253 expected = fixture ("with-exclusive-extras" )
12931254 assert locker .written_data == expected
1294- assert isinstance (installer .executor , Executor )
1255+ assert isinstance (installer .executor , TestExecutor )
12951256 if extra is None :
12961257 assert len (installer .executor .installations ) == 0
12971258 else :
@@ -1405,7 +1366,7 @@ def test_run_with_different_dependency_extras(
14051366 pool ,
14061367 config ,
14071368 installed = installed ,
1408- executor = Executor (
1369+ executor = TestExecutor (
14091370 MockEnv (),
14101371 pool ,
14111372 config ,
@@ -1422,7 +1383,7 @@ def test_run_with_different_dependency_extras(
14221383 assert locker .written_data == expected
14231384
14241385 # Results of installation are consistent with the 'extra' input
1425- assert isinstance (installer .executor , Executor )
1386+ assert isinstance (installer .executor , TestExecutor )
14261387 if extra is None :
14271388 assert len (installer .executor .installations ) == 0
14281389 else :
@@ -1645,7 +1606,7 @@ def test_run_installs_with_local_poetry_directory_and_skip_directory_flag(
16451606
16461607 assert locker .written_data == expected
16471608
1648- assert isinstance (installer .executor , Executor )
1609+ assert isinstance (installer .executor , TestExecutor )
16491610 directory_installs = [
16501611 p .name for p in installer .executor .installations if p .source_type == "directory"
16511612 ]
@@ -1928,7 +1889,7 @@ def test_run_install_duplicate_dependencies_different_constraints(
19281889
19291890 assert locker .written_data == expected
19301891
1931- assert isinstance (installer .executor , Executor )
1892+ assert isinstance (installer .executor , TestExecutor )
19321893 installs = installer .executor .installations
19331894 assert installer .executor .installations_count == 3
19341895 assert installs [0 ] == package_c12
@@ -2302,7 +2263,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
23022263 pool ,
23032264 config ,
23042265 installed = installed ,
2305- executor = Executor (env , pool , config , NullIO ()),
2266+ executor = TestExecutor (env , pool , config , NullIO ()),
23062267 )
23072268 installer .update (True )
23082269 installer .whitelist (["D" ])
@@ -2337,7 +2298,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
23372298 pool ,
23382299 config ,
23392300 installed = installed ,
2340- executor = Executor (env , pool , config , NullIO ()),
2301+ executor = TestExecutor (env , pool , config , NullIO ()),
23412302 )
23422303
23432304 package .add_dependency (
@@ -2359,7 +2320,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
23592320 locker .locked (True )
23602321 locker .mock_lock_data (locker .written_data )
23612322
2362- assert isinstance (installer .executor , Executor )
2323+ assert isinstance (installer .executor , TestExecutor )
23632324 for pkg in installer .executor .installations :
23642325 installed .add_package (pkg )
23652326
@@ -2371,7 +2332,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
23712332 pool ,
23722333 config ,
23732334 installed = installed ,
2374- executor = Executor (env , pool , config , NullIO ()),
2335+ executor = TestExecutor (env , pool , config , NullIO ()),
23752336 )
23762337 installer .update (True )
23772338 installer .whitelist (["pytest" ])
@@ -2403,7 +2364,7 @@ def test_installer_required_extras_should_be_installed(
24032364 pool ,
24042365 config ,
24052366 installed = installed ,
2406- executor = Executor (env , pool , config , NullIO ()),
2367+ executor = TestExecutor (env , pool , config , NullIO ()),
24072368 )
24082369 package .add_dependency (
24092370 Factory .create_dependency (
@@ -2430,7 +2391,7 @@ def test_installer_required_extras_should_be_installed(
24302391 pool ,
24312392 config ,
24322393 installed = installed ,
2433- executor = Executor (env , pool , config , NullIO ()),
2394+ executor = TestExecutor (env , pool , config , NullIO ()),
24342395 )
24352396 installer .update (True )
24362397 result = installer .run ()
@@ -2552,7 +2513,7 @@ def test_installer_can_install_dependencies_from_forced_source(
25522513 pool ,
25532514 config ,
25542515 installed = installed ,
2555- executor = Executor (env , pool , config , NullIO ()),
2516+ executor = TestExecutor (env , pool , config , NullIO ()),
25562517 )
25572518 installer .update (True )
25582519 result = installer .run ()
@@ -2614,7 +2575,7 @@ def test_run_installs_with_same_version_url_files(
26142575 pool ,
26152576 config ,
26162577 installed = installed ,
2617- executor = Executor (
2578+ executor = TestExecutor (
26182579 MockEnv (platform = env_platform ),
26192580 pool ,
26202581 config ,
@@ -2626,7 +2587,7 @@ def test_run_installs_with_same_version_url_files(
26262587
26272588 expected = fixture ("with-same-version-url-dependencies" )
26282589 assert locker .written_data == expected
2629- assert isinstance (installer .executor , Executor )
2590+ assert isinstance (installer .executor , TestExecutor )
26302591 assert installer .executor .installations_count == 2
26312592 demo_package = next (p for p in installer .executor .installations if p .name == "demo" )
26322593 assert demo_package .source_url == urls [env_platform ]
@@ -2776,7 +2737,7 @@ def test_installer_should_use_the_locked_version_of_git_dependencies(
27762737 result = installer .run ()
27772738 assert result == 0
27782739
2779- assert isinstance (installer .executor , Executor )
2740+ assert isinstance (installer .executor , TestExecutor )
27802741 demo_installation = next (
27812742 package
27822743 for package in installer .executor .installations
@@ -2824,7 +2785,7 @@ def test_installer_should_use_the_locked_version_of_git_dependencies_with_extras
28242785 result = installer .run ()
28252786 assert result == 0
28262787
2827- assert isinstance (installer .executor , Executor )
2788+ assert isinstance (installer .executor , TestExecutor )
28282789 assert len (installer .executor .installations ) == 3
28292790 demo_installation = next (
28302791 package
@@ -2869,7 +2830,7 @@ def test_installer_should_use_the_locked_version_of_git_dependencies_without_ref
28692830 result = installer .run ()
28702831 assert result == 0
28712832
2872- assert isinstance (installer .executor , Executor )
2833+ assert isinstance (installer .executor , TestExecutor )
28732834 assert len (installer .executor .installations ) == 2
28742835 demo_installation = next (
28752836 package
@@ -2966,7 +2927,7 @@ def test_installer_distinguishes_locked_packages_with_local_version_by_source(
29662927 pool ,
29672928 config ,
29682929 installed = installed ,
2969- executor = Executor (
2930+ executor = TestExecutor (
29702931 MockEnv (platform = env_platform ),
29712932 pool ,
29722933 config ,
@@ -2984,7 +2945,7 @@ def test_installer_distinguishes_locked_packages_with_local_version_by_source(
29842945 )
29852946 source_reference = None if env_platform == "darwin" else "pytorch"
29862947
2987- assert isinstance (installer .executor , Executor )
2948+ assert isinstance (installer .executor , TestExecutor )
29882949 assert len (installer .executor .installations ) == 1
29892950 assert installer .executor .installations [0 ] == Package (
29902951 "torch" ,
@@ -3073,7 +3034,7 @@ def test_installer_distinguishes_locked_packages_with_same_version_by_source(
30733034 pool ,
30743035 config ,
30753036 installed = installed ,
3076- executor = Executor (
3037+ executor = TestExecutor (
30773038 MockEnv (platform_machine = env_platform_machine ),
30783039 pool ,
30793040 config ,
@@ -3094,7 +3055,7 @@ def test_installer_distinguishes_locked_packages_with_same_version_by_source(
30943055 source_url = None
30953056 source_reference = None
30963057
3097- assert isinstance (installer .executor , Executor )
3058+ assert isinstance (installer .executor , TestExecutor )
30983059 assert len (installer .executor .installations ) == 1
30993060 assert installer .executor .installations [0 ] == Package (
31003061 "kivy" ,
@@ -3204,7 +3165,7 @@ def test_explicit_source_dependency_with_direct_origin_dependency(
32043165 pool ,
32053166 config ,
32063167 installed = installed ,
3207- executor = Executor (
3168+ executor = TestExecutor (
32083169 MockEnv (platform = env_platform ),
32093170 pool ,
32103171 config ,
@@ -3215,7 +3176,7 @@ def test_explicit_source_dependency_with_direct_origin_dependency(
32153176 result = installer .run ()
32163177
32173178 assert result == 0
3218- assert isinstance (installer .executor , Executor )
3179+ assert isinstance (installer .executor , TestExecutor )
32193180 if env_platform == "linux" :
32203181 assert set (installer .executor .installations ) == {
32213182 Package ("pendulum" , "1.4.4" ),
0 commit comments