code: def test_write_config_section(path=None):
      # can we handle a bare repo?
      gr = GitRepo(path, create=True, bare=True)
  
      obscure = "ds-; &%b5{}# some % "
      # test cases
      # first 3 args are write_config_section() parameters
      # 4th arg is a list with key/value pairs that should end up in a
      # ConfigManager after a reload
      testcfg = [
          (
              "submodule",
              "sub",
              dict(active="true", url="http://example.com"),
              [
                  ("submodule.sub.active", "true"),
                  ("submodule.sub.url", "http://example.com"),
              ],
          ),
          (
              "submodule",
              'sub"quote',
              {"a-b": '"quoted"', "c": 'with"quote'},
              [
                  ('submodule.sub"quote.a-b', '"quoted"'),
                  ('submodule.sub"quote.c', 'with"quote'),
              ],
          ),
          (
              "short",
              " s p a c e ",
              {"a123": " space all over "},
              [
                  ("short. s p a c e .a123", " space all over "),
              ],
          ),
          (
              "submodule",
              obscure,
              {"path": obscure, "url": f"./{obscure}"},
              [
                  (f"submodule.{obscure}.path", obscure),
                  (f"submodule.{obscure}.url", f"./{obscure}"),
              ],
          ),
      ]
  
      for tc in testcfg:
          # using append mode to provoke potential interference by
          # successive calls
          with (gr.pathobj / "config").open("a") as fobj:
              write_config_section(fobj, tc[0], tc[1], tc[2])
          gr.config.reload()
          for testcase in tc[3]:
              assert_in(testcase[0], gr.config)
              assert_equal(testcase[1], gr.config[testcase[0]])
  
imports: import logging
  import os
  from os.path import exists
  from os.path import join
  from unittest.mock import patch
  import pytest
  from datalad import cfg
  from datalad.api import create
  from datalad.cmd import CommandError
  from datalad.config import ConfigManager, _where_to_scope, parse_gitconfig_dump, rewrite_url, write_config_section
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, assert_equal, assert_false, assert_in, assert_not_equal, assert_not_in, assert_raises, assert_true, chpwd, ok_file_has_content, with_tempfile, with_testsui, with_tree
  from datalad.utils import Path, get_home_envvars, swallow_logs
label_desc: Use image node_id 16 for calling a global function with example usage: test_write_config_section(path) without return types