code: def test_cmdline_example_to_rst():
      # don't puke on nothing
      out = fmt.cmdline_example_to_rst(SIO(""))
      out.seek(0)
      ok_startswith(out.read(), ".. AUTO-GENERATED")
      out = fmt.cmdline_example_to_rst(SIO(""), ref="dummy")
      out.seek(0)
      assert_in(".. dummy:", out.read())
      # full scale test
      out = fmt.cmdline_example_to_rst(SIO(demo_example), ref="mydemo")
      out.seek(0)
      out_text = out.read()
      assert_in(".. code-block:: sh", out_text)
      assert_not_in("shame", out_text)  # no SKIP'ed
      assert_not_in("#", out_text)
  
file_path: datalad/datalad/cli/tests/test_formatters.py
imports: import importlib.util
  from io import StringIO
  from pathlib import Path
  import pytest
  from datalad.tests.utils_pytest import SkipTest, assert_in, assert_not_in, ok_, ok_startswith
  from ..parser import setup_parser
label_desc: Use image node_id 1 for calling a global function with example usage: test_cmdline_example_to_rst() without return types