code: def assert_color(
      expected: bool, default: Optional[bool] = None
  ) -> None:
      file = io.StringIO()
      if default is None:
          default = not expected
      file.isatty = lambda: default  # type: ignore
      tw = terminalwriter.TerminalWriter(file=file)
      assert tw.hasmarkup is expected
      tw.line("hello", bold=True)
      s = file.getvalue()
      if expected:
          assert len(s) > len("hello\n")
          assert "\x1b[1m" in s
          assert "\x1b[0m" in s
      else:
          assert s == "hello\n"
  
imports: import io
  import os
  import re
  import shutil
  import sys
  from pathlib import Path
  from typing import Generator
  from typing import Optional
  from unittest import mock
  import pytest
  from _pytest._io import terminalwriter
  from _pytest.monkeypatch import MonkeyPatch
label_desc: Use image node_id 7 for calling a global function with example usage: assert_color(expected, default) without return types