code: def test_providers_badre(path=None):
      """Test that a config with a bad regular expression doesn't crash
  
      Ensure that when a provider config has a bad url_re, there is no
      exception thrown and a valid warning is provided.
      """
  
      providers = Providers.from_config_files(
          files=[op.join(path, "providers.cfg")], reload=True
      )
  
      # Regexes are evaluated when get_provider is called,
      # so we need to get a random provider, even though it
      # doesn't match.
      with swallow_logs(logging.WARNING) as msg:
          the_chosen_one = providers.get_provider(
              "https://foo.org/data"
          )
          assert_in("Invalid regex", msg.out)
  
file_path: datalad/datalad/downloaders/tests/test_providers.py
imports: import logging
  import os.path
  from unittest.mock import patch
  from ...support.external_versions import external_versions
  from ...tests.utils_pytest import assert_equal, assert_false, assert_greater, assert_in, assert_raises, ok_exists, swallow_logs, with_tempfile, with_testsui, with_tree
  from ...utils import chpwd, create_tree
  from ..providers import HTTPDownloader, Provider, Providers
label_desc: Use image node_id 8 for calling a global function with example usage: test_providers_badre(path) without return types