code: def test_run(main=False):
      datas = [testcommon.getdata(i) for i in range(chkdatas)]
      cerebros = testcommon.runtest(
          datas,
          TestStrategy,
          main=main,
          plot=main,
          writer=(bt.WriterStringIO, dict(csv=True)),
      )
  
      for cerebro in cerebros:
          writer = cerebro.runwriters[0]
          if main:
              # writer.out.seek(0)
              for l in writer.out:
                  print(l.rstrip("\r\n"))
  
          else:
              lines = iter(writer.out)
              l = next(lines).rstrip("\r\n")
              assert l == "=" * 79
  
              count = 0
              while True:
                  l = next(lines).rstrip("\r\n")
                  if l[0] == "=":
                      break
                  count += 1
  
              assert count == 256
  
file_path: backtrader/tests/test_writer.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import time
  import testcommon
  import backtrader
  import backtrader.indicators
label_desc: Use image node_id 1 for calling a global function with example usage: test_run(main) without return types