code: def assert_warn_len_equal(mod, n_in_context):
      mod_warns = mod.__warningregistry__
      # Python 3 appears to clear any pre-existing warnings of the same type,
      # when raising warnings inside a catch_warnings block. So, there is a
      # warning generated by the tests within the context manager, but no
      # previous warnings.
      if "version" in mod_warns:
          assert len(mod_warns) == 2  # including 'version'
      else:
          assert len(mod_warns) == n_in_context
  
file_path: nibabel/nibabel/tests/test_testing.py
imports: import os
  import sys
  import warnings
  import numpy
  import pytest
  from ..casting import sctypes
  from ..testing import assert_allclose_safely, assert_re_in, clear_and_catch_warnings, data_path, error_warnings, get_fresh_mod, get_test_data, suppress_warnings
label_desc: Use image node_id 2 for calling a global function with example usage: assert_warn_len_equal(mod, n_in_context) without return types