summaryrefslogtreecommitdiffstats
path: root/tests/test_find_python_executable.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:26:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:26:28 +0000
commitbbbeb2d07d4f7fd0191032c219b40565fd83454f (patch)
tree3c08f1e09ed89a004867762ab40f3b610f6c0fa1 /tests/test_find_python_executable.py
parentInitial commit. (diff)
downloadflit-upstream.tar.xz
flit-upstream.zip
Adding upstream version 3.8.0.upstream/3.8.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_find_python_executable.py')
-rw-r--r--tests/test_find_python_executable.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_find_python_executable.py b/tests/test_find_python_executable.py
new file mode 100644
index 0000000..161dc7a
--- /dev/null
+++ b/tests/test_find_python_executable.py
@@ -0,0 +1,30 @@
+import os
+import re
+import sys
+
+import pytest
+
+from flit import PythonNotFoundError, find_python_executable
+
+
+def test_default():
+ assert find_python_executable(None) == sys.executable
+
+
+def test_self():
+ assert find_python_executable(sys.executable) == sys.executable
+
+
+def test_abs():
+ assert find_python_executable("/usr/bin/python") == "/usr/bin/python"
+
+
+def test_find_in_path():
+ assert os.path.isabs(find_python_executable("python"))
+
+
+@pytest.mark.parametrize("bad_python_name", ["pyhton", "ls", "."])
+def test_exception(bad_python_name: str):
+ """Test that an appropriate exception (that contains the error string) is raised."""
+ with pytest.raises(PythonNotFoundError, match=re.escape(bad_python_name)):
+ find_python_executable(bad_python_name)