@@ -57,7 +57,10 @@ fn find_pyenv_envs() {
5757 assert_messages, create_test_dispatcher, create_test_environment, join_test_paths,
5858 test_file_path,
5959 } ;
60- use python_finder:: pyenv;
60+ use python_finder:: {
61+ messaging:: { EnvManager , EnvManagerType , PythonEnvironment } ,
62+ pyenv,
63+ } ;
6164 use serde_json:: json;
6265 use std:: { collections:: HashMap , path:: PathBuf } ;
6366
@@ -74,21 +77,149 @@ fn find_pyenv_envs() {
7477 pyenv:: find_and_report ( & mut dispatcher, & known) ;
7578
7679 assert_eq ! ( dispatcher. messages. len( ) , 6 ) ;
77- let expected_manager =
78- json ! ( { "executablePath" : pyenv_exe. clone( ) , "version" : null, "tool" : "pyenv" } ) ;
79- let expected_3_9_9 = json ! ( { "projectPath" : null, "name" : null, "pythonExecutablePath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.9.9/bin/python" ] ) , "pythonRunCommand" : [ join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.9.9/bin/python" ] ) ] , "category" : "pyenv" , "version" : "3.9.9" , "envPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.9.9" ] ) , "sysPrefixPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.9.9" ] ) , "envManager" : expected_manager} ) ;
80- let expected_virtual_env = json ! ( { "projectPath" : null, "name" : "my-virtual-env" , "version" : "3.10.13" , "category" : "pyenvVirtualEnv" , "envPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/my-virtual-env" ] ) , "pythonExecutablePath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/my-virtual-env/bin/python" ] ) , "sysPrefixPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/my-virtual-env" ] ) , "pythonRunCommand" : [ join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/my-virtual-env/bin/python" ] ) ] , "envManager" : expected_manager} ) ;
81- let expected_3_12_1 = json ! ( { "projectPath" : null, "name" : null, "pythonExecutablePath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1/bin/python" ] ) , "pythonRunCommand" : [ join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1/bin/python" ] ) ] , "category" : "pyenv" , "version" : "3.12.1" , "envPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1" ] ) , "sysPrefixPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1" ] ) , "envManager" : expected_manager} ) ;
82- let expected_3_13_dev = json ! ( { "projectPath" : null, "name" : null, "pythonExecutablePath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.13-dev/bin/python" ] ) , "pythonRunCommand" : [ join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.13-dev/bin/python" ] ) ] , "category" : "pyenv" , "version" : "3.13-dev" , "envPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.13-dev" ] ) , "sysPrefixPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.13-dev" ] ) , "envManager" : expected_manager} ) ;
83- let expected_3_12_1a3 = json ! ( { "projectPath" : null, "name" : null, "pythonExecutablePath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1a3/bin/python" ] ) , "pythonRunCommand" : [ join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1a3/bin/python" ] ) ] , "category" : "pyenv" , "version" : "3.12.1a3" , "envPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1a3" ] ) , "sysPrefixPath" : join_test_paths( & [ home. to_str( ) . unwrap( ) , ".pyenv/versions/3.12.1a3" ] ) , "envManager" : expected_manager} ) ;
80+ let expected_manager = EnvManager {
81+ executable_path : pyenv_exe. clone ( ) ,
82+ version : None ,
83+ tool : EnvManagerType :: Pyenv ,
84+ } ;
85+ let expected_3_9_9 = json ! ( PythonEnvironment {
86+ project_path: None ,
87+ name: None ,
88+ python_executable_path: Some ( join_test_paths( & [
89+ home. to_str( ) . unwrap( ) ,
90+ ".pyenv/versions/3.9.9/bin/python"
91+ ] ) ) ,
92+ python_run_command: Some ( vec![ join_test_paths( & [
93+ home. to_str( ) . unwrap( ) ,
94+ ".pyenv/versions/3.9.9/bin/python"
95+ ] )
96+ . to_str( )
97+ . unwrap( )
98+ . to_string( ) ] ) ,
99+ category: python_finder:: messaging:: PythonEnvironmentCategory :: Pyenv ,
100+ version: Some ( "3.9.9" . to_string( ) ) ,
101+ env_path: Some ( join_test_paths( & [
102+ home. to_str( ) . unwrap( ) ,
103+ ".pyenv/versions/3.9.9"
104+ ] ) ) ,
105+ sys_prefix_path: Some ( join_test_paths( & [
106+ home. to_str( ) . unwrap( ) ,
107+ ".pyenv/versions/3.9.9"
108+ ] ) ) ,
109+ env_manager: Some ( expected_manager. clone( ) )
110+ } ) ;
111+ let expected_virtual_env = PythonEnvironment {
112+ project_path : None ,
113+ name : Some ( "my-virtual-env" . to_string ( ) ) ,
114+ python_executable_path : Some ( join_test_paths ( & [
115+ home. to_str ( ) . unwrap ( ) ,
116+ ".pyenv/versions/my-virtual-env/bin/python" ,
117+ ] ) ) ,
118+ python_run_command : Some ( vec ! [ join_test_paths( & [
119+ home. to_str( ) . unwrap( ) ,
120+ ".pyenv/versions/my-virtual-env/bin/python" ,
121+ ] )
122+ . to_str( )
123+ . unwrap( )
124+ . to_string( ) ] ) ,
125+ category : python_finder:: messaging:: PythonEnvironmentCategory :: PyenvVirtualEnv ,
126+ version : Some ( "3.10.13" . to_string ( ) ) ,
127+ env_path : Some ( join_test_paths ( & [
128+ home. to_str ( ) . unwrap ( ) ,
129+ ".pyenv/versions/my-virtual-env" ,
130+ ] ) ) ,
131+ sys_prefix_path : Some ( join_test_paths ( & [
132+ home. to_str ( ) . unwrap ( ) ,
133+ ".pyenv/versions/my-virtual-env" ,
134+ ] ) ) ,
135+ env_manager : Some ( expected_manager. clone ( ) ) ,
136+ } ;
137+ let expected_3_12_1 = PythonEnvironment {
138+ project_path : None ,
139+ name : None ,
140+ python_executable_path : Some ( join_test_paths ( & [
141+ home. to_str ( ) . unwrap ( ) ,
142+ ".pyenv/versions/3.12.1/bin/python" ,
143+ ] ) ) ,
144+ python_run_command : Some ( vec ! [ join_test_paths( & [
145+ home. to_str( ) . unwrap( ) ,
146+ ".pyenv/versions/3.12.1/bin/python" ,
147+ ] )
148+ . to_str( )
149+ . unwrap( )
150+ . to_string( ) ] ) ,
151+ category : python_finder:: messaging:: PythonEnvironmentCategory :: Pyenv ,
152+ version : Some ( "3.12.1" . to_string ( ) ) ,
153+ env_path : Some ( join_test_paths ( & [
154+ home. to_str ( ) . unwrap ( ) ,
155+ ".pyenv/versions/3.12.1" ,
156+ ] ) ) ,
157+ sys_prefix_path : Some ( join_test_paths ( & [
158+ home. to_str ( ) . unwrap ( ) ,
159+ ".pyenv/versions/3.12.1" ,
160+ ] ) ) ,
161+ env_manager : Some ( expected_manager. clone ( ) ) ,
162+ } ;
163+ let expected_3_13_dev = PythonEnvironment {
164+ project_path : None ,
165+ name : None ,
166+ python_executable_path : Some ( join_test_paths ( & [
167+ home. to_str ( ) . unwrap ( ) ,
168+ ".pyenv/versions/3.13-dev/bin/python" ,
169+ ] ) ) ,
170+ python_run_command : Some ( vec ! [ join_test_paths( & [
171+ home. to_str( ) . unwrap( ) ,
172+ ".pyenv/versions/3.13-dev/bin/python" ,
173+ ] )
174+ . to_str( )
175+ . unwrap( )
176+ . to_string( ) ] ) ,
177+ category : python_finder:: messaging:: PythonEnvironmentCategory :: Pyenv ,
178+ version : Some ( "3.13-dev" . to_string ( ) ) ,
179+ env_path : Some ( join_test_paths ( & [
180+ home. to_str ( ) . unwrap ( ) ,
181+ ".pyenv/versions/3.13-dev" ,
182+ ] ) ) ,
183+ sys_prefix_path : Some ( join_test_paths ( & [
184+ home. to_str ( ) . unwrap ( ) ,
185+ ".pyenv/versions/3.13-dev" ,
186+ ] ) ) ,
187+ env_manager : Some ( expected_manager. clone ( ) ) ,
188+ } ;
189+ let expected_3_12_1a3 = PythonEnvironment {
190+ project_path : None ,
191+ name : None ,
192+ python_executable_path : Some ( join_test_paths ( & [
193+ home. to_str ( ) . unwrap ( ) ,
194+ ".pyenv/versions/3.12.1a3/bin/python" ,
195+ ] ) ) ,
196+ python_run_command : Some ( vec ! [ join_test_paths( & [
197+ home. to_str( ) . unwrap( ) ,
198+ ".pyenv/versions/3.12.1a3/bin/python" ,
199+ ] )
200+ . to_str( )
201+ . unwrap( )
202+ . to_string( ) ] ) ,
203+ category : python_finder:: messaging:: PythonEnvironmentCategory :: Pyenv ,
204+ version : Some ( "3.12.1a3" . to_string ( ) ) ,
205+ env_path : Some ( join_test_paths ( & [
206+ home. to_str ( ) . unwrap ( ) ,
207+ ".pyenv/versions/3.12.1a3" ,
208+ ] ) ) ,
209+ sys_prefix_path : Some ( join_test_paths ( & [
210+ home. to_str ( ) . unwrap ( ) ,
211+ ".pyenv/versions/3.12.1a3" ,
212+ ] ) ) ,
213+ env_manager : Some ( expected_manager. clone ( ) ) ,
214+ } ;
84215 assert_messages (
85216 & [
86- expected_manager,
87- expected_3_9_9,
88- expected_virtual_env,
89- expected_3_12_1,
90- expected_3_13_dev,
91- expected_3_12_1a3,
217+ json ! ( expected_manager) ,
218+ json ! ( expected_3_9_9) ,
219+ json ! ( expected_virtual_env) ,
220+ json ! ( expected_3_12_1) ,
221+ json ! ( expected_3_13_dev) ,
222+ json ! ( expected_3_12_1a3) ,
92223 ] ,
93224 & dispatcher,
94225 )
0 commit comments