forked from bazel-contrib/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
27 lines (21 loc) · 829 Bytes
/
Copy pathtest.py
File metadata and controls
27 lines (21 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import shutil
import subprocess
import sys
import unittest
class LocalToolchainTest(unittest.TestCase):
maxDiff = None
def test_python_from_path_used(self):
shell_path = shutil.which("python3")
# We call the interpreter and print its executable because of
# things like pyenv: they install a shim that re-execs python.
# The shim is e.g. /home/user/.pyenv/shims/python3, which then
# runs e.g. /usr/bin/python3
expected = subprocess.check_output(
[shell_path, "-c", "import sys; print(sys.executable)"],
text=True,
)
expected = expected.strip().lower()
# Normalize case: Windows may have case differences
self.assertEqual(expected.lower(), sys.executable.lower())
if __name__ == "__main__":
unittest.main()