code: def test_clean_subds_removal(path=None):
      ds = Dataset(path).create()
      subds1 = ds.create("one")
      subds2 = ds.create("two")
      eq_(sorted(ds.subdatasets(result_xfm="relpaths")), ["one", "two"])
      assert_repo_status(ds.path)
      # now kill one
      res = ds.remove("one", reckless="availability", result_xfm=None)
      # subds1 got uninstalled, and ds got the removal of subds1 saved
      assert_result_count(
          res, 1, path=subds1.path, action="uninstall", status="ok"
      )
      assert_result_count(
          res, 1, path=subds1.path, action="remove", status="ok"
      )
      assert_result_count(
          res, 1, path=ds.path, action="save", status="ok"
      )
      ok_(not subds1.is_installed())
      assert_repo_status(ds.path)
      # two must remain
      eq_(ds.subdatasets(result_xfm="relpaths"), ["two"])
      # one is gone
      nok_(subds1.pathobj.exists())
      # and now again, but this time remove something that is not installed
      ds.create("three")
      eq_(
          sorted(ds.subdatasets(result_xfm="relpaths")),
          ["three", "two"],
      )
      ds.drop("two", what="all", reckless="availability")
      assert_repo_status(ds.path)
      eq_(
          sorted(ds.subdatasets(result_xfm="relpaths")),
          ["three", "two"],
      )
      nok_(subds2.is_installed())
      # oderly empty mountpoint is maintained
      ok_(subds2.pathobj.exists())
      res = ds.remove("two", reckless="availability")
      assert_in_results(
          res, path=str(ds.pathobj / "two"), action="remove"
      )
      assert_repo_status(ds.path)
      # subds2 was already uninstalled, now ds got the removal of subds2 saved
      nok_(subds2.pathobj.exists())
      eq_(ds.subdatasets(result_xfm="relpaths"), ["three"])
  
file_path: datalad/datalad/local/tests/test_remove.py
imports: import os.path
  from datalad.api import clone, remove
  from datalad.distribution.dataset import Dataset
  from datalad.tests.utils_pytest import assert_in, assert_in_results, assert_not_in, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, chpwd, create_tree, eq_, get_deeply_nested_structure, nok_, ok_, with_tempfile, with_tree
label_desc: Use image node_id 9 for calling a global function with example usage: test_clean_subds_removal(path) without return types