claudevdm commented on code in PR #36738:
URL: https://github.com/apache/beam/pull/36738#discussion_r2500960843
##########
sdks/python/apache_beam/internal/cloudpickle_pickler_test.py:
##########
@@ -220,6 +224,37 @@ def test_best_effort_determinism_not_implemented(self):
'Ignoring unsupported option: enable_best_effort_determinism',
'\n'.join(l.output))
+ @mock.patch.object(
+ beam_cloudpickle.DEFAULT_CONFIG, 'filepath_interceptor', autospec=True)
+ def test_default_config_interceptor(self, mock_filepath_interceptor):
+ """Tests config.filepath_interceptor is called for CodeType pickling."""
+ mock_filepath_interceptor.side_effect = (
+ code_object_pickler.get_normalized_path)
+
+ def sample_func():
+ return "Beam"
+
+ code_obj = sample_func.__code__
+ original_filename = os.path.abspath(code_obj.co_filename)
+
+ try:
+ pickled_code = beam_cloudpickle.dumps(code_obj)
+ unpickled_code = beam_cloudpickle.loads(pickled_code)
+
+ mock_filepath_interceptor.assert_called()
+
+ unpickled_filename = os.path.abspath(unpickled_code.co_filename)
+ self.assertEqual(unpickled_filename, original_filename)
+
+ except AttributeError as e:
Review Comment:
Why are we catching exceptions here? Seems unnecessary
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]