code: def test_to_file(tmp_path, request):
      test_str = "Hello, world!\n"
      test_path = tmp_path / request.node.name
  
      ByteStream(test_str.encode()).to_file(test_path)
      with open(test_path, "rb") as fd:
          assert fd.read().decode() == test_str
  
imports: import io
  from haystack.dataclasses import ByteStream
  import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: test_to_file(tmp_path, request) without return types