Skip to content

Commit 23f55d3

Browse files
committed
test: Add unit test for get_python_version
1 parent 3961637 commit 23f55d3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/unit/functions/test_remote_function_utils.py

Lines changed: 23 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,28 @@ 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+
"""
247+
Tests the python version string formatting for both standard and compat modes.
248+
"""
249+
result = _utils.get_python_version(is_compat=is_compat)
250+
assert result == expected_version
251+
252+
230253
def test_package_existed_helper():
231254
"""Tests the _package_existed helper function directly."""
232255
reqs = ["pandas==1.0", "numpy", "scikit-learn>=1.2.0"]

0 commit comments

Comments
 (0)