code: def test_py_file_update(ast_transformer, pasta_parse, pasta_dump):
      input_ast = Mock()
      pasta_parse.return_value = input_ast
  
      output_ast = Mock(_fields=[])
      ast_transformer.return_value.visit.return_value = output_ast
      output_code = "print('goodbye')"
      pasta_dump.return_value = output_code
  
      input_file = "input.py"
      output_file = "output.py"
  
      input_code = "print('hello, world!')"
      open_mock = mock_open(read_data=input_code)
      with patch("six.moves.builtins.open", open_mock):
          updater = files.PyFileUpdater(input_file, output_file)
          updater.update()
  
      pasta_parse.assert_called_with(input_code)
      ast_transformer.return_value.visit.assert_called_with(input_ast)
  
      assert call(input_file) in open_mock.mock_calls
      assert call(output_file, "w") in open_mock.mock_calls
  
      open_mock().write.assert_called_with(output_code)
      pasta_dump.assert_called_with(output_ast)
  
file_path: sagemaker-python-sdk/tests/unit/sagemaker/cli/compatibility/v2/test_file_updaters.py
imports: from __future__ import absolute_import
  import json
  import os
  from mock import call, Mock, mock_open, patch
  from sagemaker.cli.compatibility.v2 import files
label_desc: Use image node_id 4 for calling a global function with example usage: test_py_file_update(ast_transformer, pasta_parse, pasta_dump) without return types