code: def test_license_headers(self):
      exclude_patterns = (
          "build/*",
          "dist/*",
          "docs/build/*",
          "docs/source/gallery/*",
          "examples/*",
          "lib/cartopy/_version.py",
      )
  
      try:
          tracked_files = self.list_tracked_files()
      except ValueError as e:
          # Caught the case where this is not a git repo.
          return pytest.skip(
              "cartopy installation did not look like a git "
              f"repo: {e}"
          )
  
      failed = []
      for fname in sorted(tracked_files):
          full_fname = REPO_DIR / fname
          ext = full_fname.suffix
          if (
              ext in (".py", ".pyx", ".c", ".cpp", ".h")
              and full_fname.is_file()
              and not any(
                  fnmatch(fname, pat) for pat in exclude_patterns
              )
          ):
              if full_fname.stat().st_size == 0:
                  # Allow completely empty files (e.g. ``__init__.py``)
                  continue
  
              with open(full_fname, encoding="utf-8") as fh:
                  content = fh.read()
  
              if not bool(LICENSE_RE.match(content)):
                  failed.append(full_fname)
  
      assert failed == [], "There were license header failures."
  
file_path: cartopy/lib/cartopy/tests/test_coding_standards.py
imports: from fnmatch import fnmatch
  import os
  from pathlib import Path
  import re
  import subprocess
  import pytest
  import cartopy
label_desc: Use image node_id 2 for calling the TestLicenseHeaders obj's underlying member method code with example usage: obj.test_license_headers() and returns: pytest