I'm writing a python unit test using unittest and I want to compile some Solidity contracts in the test setup.
However, when I did the compile by os.system() or subprocess.run(), it shows that solc, the Solidity compiler, not found. While it runs properly when running in a non-test python program.
After this happens, I found a further interesting things: when I print(os.environ) in both a test python program using unittest and a normal python program, the result is of hugh difference! Including the most important one: $PATH. It looks like the following:
****PATH in unittest****
/usr/bin
/usr/local/bin
...(mostly the default $PATH set by Linux)
****PATH in normal program****
/usr/bin
/.../myEnvs/.../bin
...(as same as my console's $PATH, which is exported in .bashrc)
Since I'm working with others to develop this program, I should NOT add path such as "myEnvs" in program (by using environment setting like env= parameter provided by subprocess.Popen()).
I think the abnormal $PATH in python.unittest is caused by some configurations introduced by VScode, so what are these configs? How could I modify them? or this "PATH inconsistence" is caused by some other reasons?