code: def test_globbedpaths(path=None):
      dotdir = op.curdir + op.sep
  
      for patterns, expected in [
          (["1.txt", "2.dat"], {"1.txt", "2.dat"}),
          ([dotdir + "1.txt", "2.dat"], {dotdir + "1.txt", "2.dat"}),
          (
              ["*.txt", "*.dat"],
              {"1.txt", "2.dat", bOBSCURE_FILENAME, "3.txt"},
          ),
          (
              [dotdir + "*.txt", "*.dat"],
              {
                  dotdir + "1.txt",
                  "2.dat",
                  bOBSCURE_FILENAME,
                  dotdir + "3.txt",
              },
          ),
          (
              [op.join("subdir", "*.txt")],
              {op.join("subdir", "1.txt"), op.join("subdir", "2.txt")},
          ),
          (["subdir" + op.sep], {"subdir" + op.sep}),
          (
              [dotdir + op.join("subdir", "*.txt")],
              {
                  dotdir + op.join(*ps)
                  for ps in [("subdir", "1.txt"), ("subdir", "2.txt")]
              },
          ),
          (["*.txt"], {"1.txt", "3.txt"}),
          (
              [op.join("subdir", "**")],
              {
                  op.join(*ps)
                  for ps in [
                      ("subdir" + op.sep,),
                      ("subdir", "subsub"),
                      ("subdir", "1.txt"),
                      ("subdir", "2.txt"),
                      ("subdir", "subsub", "3.dat"),
                  ]
              },
          ),
          (
              [dotdir + op.join("**", "*.dat")],
              {
                  dotdir + op.join("2.dat"),
                  dotdir + bOBSCURE_FILENAME,
                  dotdir + op.join("subdir", "subsub", "3.dat"),
              },
          ),
      ]:
          gp = GlobbedPaths(patterns, pwd=path)
          eq_(set(gp.expand()), expected)
          eq_(
              set(gp.expand(full=True)),
              {op.join(path, p) for p in expected},
          )
  
      pardir = op.pardir + op.sep
      subdir_path = op.join(path, "subdir")
      for patterns, expected in [
          (["*.txt"], {"1.txt", "2.txt"}),
          (
              [dotdir + "*.txt"],
              {dotdir + p for p in ["1.txt", "2.txt"]},
          ),
          (
              [pardir + "*.txt"],
              {pardir + p for p in ["1.txt", "3.txt"]},
          ),
          (
              [dotdir + pardir + "*.txt"],
              {dotdir + pardir + p for p in ["1.txt", "3.txt"]},
          ),
          # Patterns that don't match are retained by default.
          (["amiss"], {"amiss"}),
      ]:
          gp = GlobbedPaths(patterns, pwd=subdir_path)
          eq_(set(gp.expand()), expected)
          eq_(
              set(gp.expand(full=True)),
              {op.join(subdir_path, p) for p in expected},
          )
  
      # Full patterns still get returned as relative to pwd.
      gp = GlobbedPaths([op.join(path, "*.dat")], pwd=path)
      eq_(gp.expand(), ["2.dat", bOBSCURE_FILENAME])
  
      # "." gets special treatment.
      gp = GlobbedPaths([".", "*.dat"], pwd=path)
      eq_(set(gp.expand()), {"2.dat", bOBSCURE_FILENAME, "."})
      eq_(gp.expand(dot=False), ["2.dat", bOBSCURE_FILENAME])
      gp = GlobbedPaths(["."], pwd=path, expand=False)
      eq_(gp.expand(), ["."])
      eq_(gp.paths, ["."])
  
      # We can the glob outputs.
      glob_results = {"z": "z", "a": ["x", "d", "b"]}
      with patch("glob.glob", lambda k, **kwargs: glob_results[k]):
          gp = GlobbedPaths(["z", "a"])
          eq_(gp.expand(), ["z", "b", "d", "x"])
  
      # glob expansion for paths property is determined by expand argument.
      for expand, expected in [
          (True, ["2.dat", bOBSCURE_FILENAME]),
          (False, ["*.dat"]),
      ]:
          gp = GlobbedPaths(["*.dat"], pwd=path, expand=expand)
          eq_(gp.paths, expected)
  
      with swallow_logs(new_level=logging.DEBUG) as cml:
          GlobbedPaths(["not here"], pwd=path).expand()
          assert_in("No matching files found for 'not here'", cml.out)
  
file_path: datalad/datalad/support/tests/test_globbedpaths.py
imports: import logging
  import os.path
  from itertools import product
  from unittest.mock import patch
  from datalad.tests.utils_pytest import OBSCURE_FILENAME, assert_in, eq_, swallow_logs, with_tree
  from ..globbedpaths import GlobbedPaths
label_desc: Use image node_id 2 for calling a global function with example usage: test_globbedpaths(path) without return types