code: def test_dataset_id(path=None):
      ds = Dataset(path)
      assert_equal(ds.id, None)
      ds.create()
      dsorigid = ds.id
      # ID is always a UUID
      assert_equal(ds.id.count("-"), 4)
      assert_equal(len(ds.id), 36)
  
      # Ben: The following part of the test is concerned with creating new objects
      #      and therefore used to reset the flyweight dict while keeping a ref to
      #      the old object for comparison etc. This is ugly and in parts
      #      retesting what is already tested in `test_Dataset_flyweight`. No need
      #      for that. If we del the last ref to an instance and gc.collect(),
      #      then we get a new instance on next request. This test should trust
      #      the result of `test_Dataset_flyweight`.
  
      # creating a new object for the same path
      # yields the same ID
      del ds
      newds = Dataset(path)
      assert_equal(dsorigid, newds.id)
  
      # recreating the dataset does NOT change the id
      del newds
  
      ds = Dataset(path)
      ds.create(annex=False, force=True)
      assert_equal(ds.id, dsorigid)
  
      # even adding an annex doesn't
      del ds
      ds = Dataset(path)
      ds.create(force=True)
      assert_equal(ds.id, dsorigid)
  
      # dataset ID and annex UUID have nothing to do with each other
      # if an ID was already generated
      assert_true(ds.repo.uuid != ds.id)
  
      # even if we generate a dataset from scratch with an annex UUID right away,
      # this is also not the ID
      annexds = Dataset(opj(path, "scratch")).create()
      assert_true(annexds.id != annexds.repo.uuid)
  
imports: import os
  import os.path
  from os.path import abspath
  from os.path import join
  from os.path import lexists, relpath
  import pytest
  import datalad.utils
  from datalad import cfg
  from datalad.api import clone, create, get
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import NoDatasetFound
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import OBSCURE_FILENAME, SkipTest, assert_equal, assert_false, assert_is, assert_is_instance, assert_is_none, assert_is_not, assert_is_not_none, assert_not_equal, assert_not_in, assert_raises, assert_repo_status, assert_result_count, assert_true, eq_, known_failure_windows, ok_, swallow_logs, with_tempfile
  from datalad.utils import Path, _path_, chpwd, on_windows, rmtree
  from ..dataset import Dataset, EnsureDataset, require_dataset, resolve_path
label_desc: Use image node_id 8 for calling a global function with example usage: test_dataset_id(path) without return types