code: def test__ensure_cr():
      # Make sure text ends with carriage return
      assert _ensure_cr("  foo") == "  foo\n"
      assert _ensure_cr("  foo\n") == "  foo\n"
      assert _ensure_cr("  foo  ") == "  foo\n"
      assert _ensure_cr("foo  ") == "foo\n"
      assert _ensure_cr("foo  \n bar") == "foo  \n bar\n"
      assert _ensure_cr("foo  \n\n") == "foo\n"
  
file_path: nibabel/nibabel/tests/test_deprecator.py
imports: import sys
  import warnings
  from functools import partial
  from textwrap import indent
  import pytest
  from nibabel.deprecator import TESTCLEANUP, TESTSETUP, Deprecator, ExpiredDeprecationError, _add_dep_doc, _ensure_cr
  from ..testing import clear_and_catch_warnings
label_desc: Use image node_id 1 for calling a global function with example usage: test__ensure_cr() without return types