code: def test_sink_to_textfile_named():
      source = Stream()
      with tmpfile() as filename:
          _sink = source.map(str).sink_to_textfile(filename)
          source.emit(0)
          source.emit(1)
  
          _sink._fp.flush()
  
          assert open(filename, "r").read() == "0\n1\n"
  
file_path: streamz/streamz/tests/test_sinks.py
imports: import weakref
  import pytest
  from streamz import Stream
  from streamz.sinks import _global_sinks, Sink
  from streamz.utils_test import tmpfile, wait_for
label_desc: Use image node_id 3 for calling a global function with example usage: test_sink_to_textfile_named() without return types