code: def test_create_raises(path=None, outside_path=None):
      ds = Dataset(path)
      # incompatible arguments (annex only):
      assert_raises(
          ValueError, ds.create, annex=False, description="some"
      )
  
      with open(op.join(path, "somefile.tst"), "w") as f:
          f.write("some")
      # non-empty without `force`:
      assert_in_results(
          ds.create(force=False, **raw),
          status="error",
          message="will not create a dataset in a non-empty directory, use `--force` option to ignore",
      )
      # non-empty with `force`:
      ds.create(force=True)
      # create sub outside of super:
      assert_in_results(
          ds.create(outside_path, **raw),
          status="error",
          message=(
              "dataset containing given paths is not underneath the reference "
              "dataset %s: %s",
              ds,
              outside_path,
          ),
      )
      obscure_ds = "ds-" + OBSCURE_FILENAME
      # create a sub:
      ds.create(obscure_ds)
      # fail when doing it again
      assert_in_results(
          ds.create(obscure_ds, **raw),
          status="error",
          message=(
              "collision with %s (dataset) in dataset %s",
              str(ds.pathobj / obscure_ds),
              ds.path,
          ),
      )
  
      # now deinstall the sub and fail trying to create a new one at the
      # same location
      ds.drop(obscure_ds, what="all", reckless="kill", recursive=True)
      assert_in(
          obscure_ds,
          ds.subdatasets(state="absent", result_xfm="relpaths"),
      )
      # and now should fail to also create inplace or under
      assert_in_results(
          ds.create(obscure_ds, **raw),
          status="error",
          message=(
              "collision with %s (dataset) in dataset %s",
              str(ds.pathobj / obscure_ds),
              ds.path,
          ),
      )
      assert_in_results(
          ds.create(op.join(obscure_ds, "subsub"), **raw),
          status="error",
          message=(
              "collision with %s (dataset) in dataset %s",
              str(ds.pathobj / obscure_ds),
              ds.path,
          ),
      )
      os.makedirs(op.join(ds.path, "down"))
      with open(
          op.join(ds.path, "down", "someotherfile.tst"), "w"
      ) as f:
          f.write("someother")
      ds.save()
      assert_in_results(
          ds.create("down", **raw),
          status="error",
          message=(
              "collision with content in parent dataset at %s: %s",
              ds.path,
              [str(ds.pathobj / "down" / "someotherfile.tst")],
          ),
      )
  
imports: import os
  import os.path
  import pytest
  from datalad.api import create
  from datalad.cmd import WitlessRunner
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CommandError
  from datalad.tests.utils_pytest import OBSCURE_FILENAME, assert_in, assert_in_results, assert_not_in, assert_raises, assert_repo_status, assert_status, eq_, has_symlink_capability, ok_, ok_exists, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import Path, chpwd
label_desc: Use image node_id 1 for calling a global function with example usage: test_create_raises(path, outside_path) without return types