Skip to content

Commit 1e4bd73

Browse files
authored
Merge pull request #39328 from shunping/fix-test-get-python-sdk-name
Fix test_get_python_sdk_name to use supported Python version
2 parents 24a6dbd + 2707175 commit 1e4bd73

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

sdks/python/apache_beam/runners/dataflow/internal/apiclient.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,10 @@ def _verify_interpreter_version_is_supported(pipeline_options):
12621262
return
12631263

12641264
raise Exception(
1265-
'Dataflow runner currently supports Python versions %s, got %s.\n'
1265+
'Dataflow runner currently supports Python versions %s, got %s.%s.\n'
12661266
'To ignore this requirement and start a job '
12671267
'using an unsupported version of Python interpreter, pass '
1268-
'--experiment use_unsupported_python_version pipeline option.' %
1269-
(_PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW, sys.version))
1268+
'--experiment use_unsupported_python_version pipeline option.' % (
1269+
_PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW,
1270+
sys.version_info[0],
1271+
sys.version_info[1]))

sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,12 @@ def test_experiment_use_multiple_sdk_containers(self):
10301030
self.assertNotIn(
10311031
'use_multiple_sdk_containers', environment.proto.experiments)
10321032

1033+
# Note: We mock Python to 3.11 here. Keep this mocked version aligned with a
1034+
# version in _PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW to prevent test failures
1035+
# on release (non-dev) builds.
10331036
@mock.patch(
10341037
'apache_beam.runners.dataflow.internal.apiclient.sys.version_info',
1035-
(3, 9))
1038+
(3, 11))
10361039
def test_get_python_sdk_name(self):
10371040
pipeline_options = PipelineOptions([
10381041
'--project',
@@ -1051,7 +1054,7 @@ def test_get_python_sdk_name(self):
10511054
'1',
10521055
FAKE_PIPELINE_URL)
10531056
self.assertEqual(
1054-
'Apache Beam Python 3.9 SDK', environment._get_python_sdk_name())
1057+
'Apache Beam Python 3.11 SDK', environment._get_python_sdk_name())
10551058

10561059
@mock.patch(
10571060
'apache_beam.runners.dataflow.internal.apiclient.sys.version_info',

0 commit comments

Comments
 (0)