MCPcopy
hub / github.com/dask/dask / test__get_paths

Function test__get_paths

dask/tests/test_config.py:712–746  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

710
711
712def test__get_paths(monkeypatch):
713 # These settings are used by Dask's config system. We temporarily
714 # remove them to avoid interference from the machine where tests
715 # are being run.
716 monkeypatch.delenv("DASK_CONFIG", raising=False)
717 monkeypatch.delenv("DASK_ROOT_CONFIG", raising=False)
718 monkeypatch.setattr(site, "PREFIXES", [])
719
720 expected = [
721 "/etc/dask",
722 os.path.join(sys.prefix, "etc", "dask"),
723 os.path.join(os.path.expanduser("~"), ".config", "dask"),
724 ]
725 paths = _get_paths()
726 assert paths == expected
727 assert len(paths) == len(set(paths)) # No duplicate paths
728
729 with monkeypatch.context() as m:
730 m.setenv("DASK_CONFIG", "foo-bar")
731 paths = _get_paths()
732 assert paths == expected + ["foo-bar"]
733 assert len(paths) == len(set(paths))
734
735 with monkeypatch.context() as m:
736 m.setenv("DASK_ROOT_CONFIG", "foo-bar")
737 paths = _get_paths()
738 assert paths == ["foo-bar"] + expected[1:]
739 assert len(paths) == len(set(paths))
740
741 with monkeypatch.context() as m:
742 prefix = os.path.join("include", "this", "path")
743 m.setattr(site, "PREFIXES", site.PREFIXES + [prefix])
744 paths = _get_paths()
745 assert os.path.join(prefix, "etc", "dask") in paths
746 assert len(paths) == len(set(paths))
747
748
749def test_default_search_paths():

Callers

nothing calls this directly

Calls 3

_get_pathsFunction · 0.90
setClass · 0.85
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…