Skip to content

Commit 7072627

Browse files
authored
test: Add unit test for get_python_version (#2041)
* test: Add unit test for get_python_version * fix
1 parent 7ac6fe1 commit 7072627

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/unit/functions/test_remote_function_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import inspect
16+
import sys
1617
from unittest.mock import patch
1718

1819
import bigframes_vendored.constants as constants
@@ -227,6 +228,26 @@ def test_get_updated_package_requirements_with_existing_cloudpickle():
227228
assert result == expected
228229

229230

231+
# Dynamically generate expected python versions for the test
232+
_major = sys.version_info.major
233+
_minor = sys.version_info.minor
234+
_compat_version = f"python{_major}{_minor}"
235+
_standard_version = f"python-{_major}.{_minor}"
236+
237+
238+
@pytest.mark.parametrize(
239+
"is_compat, expected_version",
240+
[
241+
(True, _compat_version),
242+
(False, _standard_version),
243+
],
244+
)
245+
def test_get_python_version(is_compat, expected_version):
246+
"""Tests the python version for both standard and compat modes."""
247+
result = _utils.get_python_version(is_compat=is_compat)
248+
assert result == expected_version
249+
250+
230251
def test_package_existed_helper():
231252
"""Tests the _package_existed helper function directly."""
232253
reqs = ["pandas==1.0", "numpy", "scikit-learn>=1.2.0"]

0 commit comments

Comments
 (0)