(monkeypatch)
| 642 | |
| 643 | |
| 644 | def test__get_paths(monkeypatch): |
| 645 | # These settings are used by Dask's config system. We temporarily |
| 646 | # remove them to avoid interference from the machine where tests |
| 647 | # are being run. |
| 648 | monkeypatch.delenv("DASK_CONFIG", raising=False) |
| 649 | monkeypatch.delenv("DASK_ROOT_CONFIG", raising=False) |
| 650 | monkeypatch.setattr(site, "PREFIXES", []) |
| 651 | |
| 652 | expected = [ |
| 653 | "/etc/dask", |
| 654 | os.path.join(sys.prefix, "etc", "dask"), |
| 655 | os.path.join(os.path.expanduser("~"), ".config", "dask"), |
| 656 | ] |
| 657 | paths = _get_paths() |
| 658 | assert paths == expected |
| 659 | assert len(paths) == len(set(paths)) # No duplicate paths |
| 660 | |
| 661 | with monkeypatch.context() as m: |
| 662 | m.setenv("DASK_CONFIG", "foo-bar") |
| 663 | paths = _get_paths() |
| 664 | assert paths == expected + ["foo-bar"] |
| 665 | assert len(paths) == len(set(paths)) |
| 666 | |
| 667 | with monkeypatch.context() as m: |
| 668 | m.setenv("DASK_ROOT_CONFIG", "foo-bar") |
| 669 | paths = _get_paths() |
| 670 | assert paths == ["foo-bar"] + expected[1:] |
| 671 | assert len(paths) == len(set(paths)) |
| 672 | |
| 673 | with monkeypatch.context() as m: |
| 674 | prefix = os.path.join("include", "this", "path") |
| 675 | m.setattr(site, "PREFIXES", site.PREFIXES + [prefix]) |
| 676 | paths = _get_paths() |
| 677 | assert os.path.join(prefix, "etc", "dask") in paths |
| 678 | assert len(paths) == len(set(paths)) |
| 679 | |
| 680 | |
| 681 | def test_default_search_paths(): |
nothing calls this directly
no test coverage detected