code: def test_run(main=False):
      datas = [testcommon.getdata(i) for i in range(chkdatas)]
      cerebros = testcommon.runtest(
          datas,
          TestStrategy,
          printdata=main,
          stocklike=False,
          printops=main,
          plot=main,
          analyzer=(
              bt.analyzers.TimeReturn,
              dict(timeframe=bt.TimeFrame.Years),
          ),
      )
  
      for cerebro in cerebros:
          strat = cerebro.runstrats[0][0]  # no optimization, only 1
          analyzer = strat.analyzers[0]  # only 1
          analysis = analyzer.get_analysis()
          if main:
              print(analysis)
              print(str(analysis[next(iter(analysis.keys()))]))
          else:
              # Handle different precision
              if PY2:
                  sval = "0.2795"
              else:
                  sval = "0.2794999999999983"
  
              assert str(analysis[next(iter(analysis.keys()))]) == sval
  
file_path: backtrader/tests/test_analyzer-timereturn.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import time
  import testcommon
  import backtrader
  import backtrader.indicators
  from backtrader.utils.py3 import PY2
label_desc: Use image node_id 1 for calling a global function with example usage: test_run(main) without return types