code: def test_report_strings():
      rep = Report()
      assert rep.__str__() != ""
      assert rep.message == ""
      str_io = StringIO()
      rep.write_raise(str_io)
      assert str_io.getvalue() == ""
      rep = Report(ValueError, 20, "msg", "fix")
      rep.write_raise(str_io)
      assert str_io.getvalue() == ""
      rep.problem_level = 30
      rep.write_raise(str_io)
      assert str_io.getvalue() == "Level 30: msg; fix\n"
      str_io.truncate(0)
      str_io.seek(0)
      # No fix string, no fix message
      rep.fix_msg = ""
      rep.write_raise(str_io)
      assert str_io.getvalue() == "Level 30: msg\n"
      rep.fix_msg = "fix"
      str_io.truncate(0)
      str_io.seek(0)
      # If we drop the level, nothing goes to the log
      rep.problem_level = 20
      rep.write_raise(str_io)
      assert str_io.getvalue() == ""
      # Unless we set the default log level in the call
      rep.write_raise(str_io, log_level=20)
      assert str_io.getvalue() == "Level 20: msg; fix\n"
      str_io.truncate(0)
      str_io.seek(0)
      # If we set the error level down this low, we raise an error
      with pytest.raises(ValueError):
          rep.write_raise(str_io, 20)
      # But the log level wasn't low enough to do a log entry
      assert str_io.getvalue() == ""
      # Error still raised with lower log threshold, but now we do get a
      # log entry
      with pytest.raises(ValueError):
          rep.write_raise(str_io, 20, 20)
      assert str_io.getvalue() == "Level 20: msg; fix\n"
      # If there's no error, we can't raise
      str_io.truncate(0)
      str_io.seek(0)
      rep.error = None
      rep.write_raise(str_io, 20)
      assert str_io.getvalue() == ""
  
file_path: nibabel/nibabel/tests/test_batteryrunners.py
imports: import logging
  from io import StringIO
  import pytest
  from ..batteryrunners import BatteryRunner, Report
label_desc: Use image node_id 7 for calling a global function with example usage: test_report_strings() without return types