diff --git a/spine_engine/config.py b/spine_engine/config.py
index cfd3387..58ebcaa 100644
--- a/spine_engine/config.py
+++ b/spine_engine/config.py
@@ -10,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Application constants.
-
-"""
-
+"""Spine Engine constants."""
import os
import sys
diff --git a/spine_engine/utils/helpers.py b/spine_engine/utils/helpers.py
index 6025dd5..121fad8 100644
--- a/spine_engine/utils/helpers.py
+++ b/spine_engine/utils/helpers.py
@@ -130,9 +130,10 @@ def resolve_current_python_interpreter():
"""
if not is_frozen():
return sys.executable
- path = resolve_executable_from_path(PYTHON_EXECUTABLE)
- if path != "":
- return path
+ if not sys.platform == "win32":
+ path = resolve_executable_from_path(PYTHON_EXECUTABLE)
+ if path != "":
+ return path
return EMBEDDED_PYTHON
diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py
index 9e8c48b..ef8f41c 100644
--- a/tests/utils/test_helpers.py
+++ b/tests/utils/test_helpers.py
@@ -10,16 +10,20 @@
# this program. If not, see .
######################################################################################################################
-"""
-Unit tests for chunk module.
-
-"""
+"""Unit tests for chunk module."""
+import sys
import unittest
-
+from unittest import mock
from spine_engine.project_item.connection import Connection, FilterSettings
from spinedb_api.filters.scenario_filter import SCENARIO_FILTER_TYPE
from spinedb_api.helpers import remove_credentials_from_url
-from spine_engine.utils.helpers import make_dag, gather_leaf_data, get_file_size, required_items_for_execution
+from spine_engine.utils.helpers import (
+ make_dag,
+ gather_leaf_data,
+ get_file_size,
+ required_items_for_execution,
+ resolve_python_interpreter,
+)
class TestRequiredItemsForExecution(unittest.TestCase):
@@ -188,5 +192,31 @@ def test_get_file_size(self):
self.assertEqual(expected_output, output)
+class TestPythonInterpreter(unittest.TestCase):
+ def test_resolve_python_interpreter(self):
+ expected_path = "path_to_python"
+ settings = TestAppSettings(expected_path)
+ p = resolve_python_interpreter(settings)
+ self.assertEqual(expected_path, p)
+ settings = TestAppSettings("")
+ p = resolve_python_interpreter(settings)
+ self.assertEqual(sys.executable, p)
+ if sys.platform == "win32":
+ with mock.patch("spine_engine.utils.helpers.is_frozen") as mock_helpers_is_frozen:
+ mock_helpers_is_frozen.return_value = True
+ p = resolve_python_interpreter(settings)
+ self.assertIsNone(p) # This is None only on Win. # FIXME: Find a way to mock is_frozen() in config.py
+ mock_helpers_is_frozen.assert_called()
+
+
+class TestAppSettings:
+ def __init__(self, test_path):
+ self.test_path = test_path
+
+ def value(self, key):
+ if key == "appSettings/pythonPath":
+ return self.test_path
+
+
if __name__ == "__main__":
unittest.main()