Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e200cae

Browse files
committed
Add PYTHONPATH/PYTHONHOME default value tests
Current tests crash on 64bit python on windows, and results get truncated on Linux. When working, PYTHONHOME should match ENV VAR if set. AppVeyor has been updated to test against not blank
1 parent 6f3f357 commit e200cae

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ init:
2727
# Put desired Python version first in PATH
2828
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
2929

30+
# Needed for test `GetPythonHomeDefault`
31+
- set PYTHONHOME=%PYTHON%
32+
3033
install:
3134
- pip install --upgrade -r requirements.txt --quiet
3235

src/embed_tests/TestPythonEngineProperties.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,44 @@ public static void GetVersionDoesntCrash()
6666
Assert.IsTrue(s.Contains(","));
6767
}
6868
}
69+
70+
[Test]
71+
public static void GetPythonPathDefault()
72+
{
73+
PythonEngine.Initialize();
74+
string s = PythonEngine.PythonPath;
75+
76+
StringAssert.Contains("python", s.ToLower());
77+
PythonEngine.Shutdown();
78+
}
79+
80+
[Test]
81+
public static void GetProgramNameDefault()
82+
{
83+
PythonEngine.Initialize();
84+
string s = PythonEngine.PythonHome;
85+
86+
Assert.NotNull(s);
87+
PythonEngine.Shutdown();
88+
}
89+
90+
/// <summary>
91+
/// Test default behavior of PYTHONHOME. If ENVVAR is set it will
92+
/// return the same value. If not, returns EmptyString.
93+
/// </summary>
94+
/// <remarks>
95+
/// AppVeyor.yml has been update to tests with ENVVAR set.
96+
/// </remarks>
97+
[Test]
98+
public static void GetPythonHomeDefault()
99+
{
100+
string envPythonHome = Environment.GetEnvironmentVariable("PYTHONHOME") ?? "";
101+
102+
PythonEngine.Initialize();
103+
string enginePythonHome = PythonEngine.PythonHome;
104+
105+
Assert.AreEqual(envPythonHome, enginePythonHome);
106+
PythonEngine.Shutdown();
107+
}
69108
}
70109
}

0 commit comments

Comments
 (0)