@@ -142,5 +142,46 @@ public void SetProgramName()
142142 Assert . AreEqual ( programName , PythonEngine . ProgramName ) ;
143143 PythonEngine . Shutdown ( ) ;
144144 }
145+
146+ [ Test ]
147+ public void SetPythonPath ( )
148+ {
149+ if ( Runtime . Runtime . pyversion == "2.7" )
150+ {
151+ // Assert.Skip outputs as a warning (ie. pending to fix)
152+ Assert . Pass ( ) ;
153+ }
154+
155+ PythonEngine . Initialize ( ) ;
156+ string path = PythonEngine . PythonPath ;
157+ PythonEngine . Shutdown ( ) ;
158+
159+ PythonEngine . ProgramName = path ;
160+ PythonEngine . Initialize ( ) ;
161+
162+ Assert . AreEqual ( path , PythonEngine . PythonPath ) ;
163+ PythonEngine . Shutdown ( ) ;
164+ }
165+
166+ [ Test ]
167+ public void SetPythonPathExceptionOn27 ( )
168+ {
169+ if ( Runtime . Runtime . pyversion != "2.7" )
170+ {
171+ Assert . Pass ( ) ;
172+ }
173+
174+ // Get previous path to avoid crashing Python
175+ PythonEngine . Initialize ( ) ;
176+ string path = PythonEngine . PythonPath ;
177+ PythonEngine . Shutdown ( ) ;
178+
179+ var ex = Assert . Throws < NotSupportedException > ( ( ) => PythonEngine . PythonPath = "foo" ) ;
180+ Assert . AreEqual ( "Set PythonPath not supported on Python 2" , ex . Message ) ;
181+
182+ PythonEngine . Initialize ( ) ;
183+ Assert . AreEqual ( path , PythonEngine . PythonPath ) ;
184+ PythonEngine . Shutdown ( ) ;
185+ }
145186 }
146187}
0 commit comments