|
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 |
|
7 | | -from pyrootutils import get_root, set_root, setup_root |
| 7 | +from pyrootutils import find_root, set_root, setup_root |
8 | 8 |
|
9 | 9 |
|
10 | 10 | def test_pyrootutils(): |
11 | | - assert get_root |
| 11 | + assert find_root |
12 | 12 | assert set_root |
13 | 13 | assert setup_root |
14 | 14 |
|
15 | 15 |
|
16 | | -def test_get_root(): |
17 | | - path = get_root(__file__) |
| 16 | +def test_find_root(): |
| 17 | + path = find_root(__file__) |
18 | 18 | assert path.exists() |
19 | 19 |
|
20 | | - path = get_root(str(__file__)) |
| 20 | + path = find_root(str(__file__)) |
21 | 21 | assert path.exists() |
22 | 22 |
|
23 | | - path = get_root(Path(__file__)) |
| 23 | + path = find_root(Path(__file__)) |
24 | 24 | assert path.exists() |
25 | 25 |
|
26 | | - path = get_root(__file__, ".git") |
| 26 | + path = find_root(__file__, ".git") |
27 | 27 | assert path.exists() |
28 | 28 |
|
29 | | - path = get_root(__file__, indicator=[".setup.cfg", "setup.py", "LICENSE"]) |
| 29 | + path = find_root(__file__, indicator=[".setup.cfg", "setup.py", "LICENSE"]) |
30 | 30 | assert path.exists() |
31 | 31 |
|
32 | | - path = get_root("") |
| 32 | + path = find_root("") |
33 | 33 | assert path.exists() |
34 | 34 |
|
35 | | - path = get_root(".") |
| 35 | + path = find_root(".") |
36 | 36 | assert path.exists() |
37 | 37 |
|
38 | 38 | with pytest.raises(FileNotFoundError): |
39 | | - path = get_root(__file__, indicator="abc") |
| 39 | + path = find_root(__file__, indicator="abc") |
40 | 40 |
|
41 | 41 | with pytest.raises(FileNotFoundError): |
42 | | - path = get_root(__file__, indicator=["abc", "def", "fgh"]) |
| 42 | + path = find_root(__file__, indicator=["abc", "def", "fgh"]) |
43 | 43 |
|
44 | 44 | with pytest.raises(FileNotFoundError): |
45 | | - path = get_root(Path(__file__).parent.parent.parent) |
| 45 | + path = find_root(Path(__file__).parent.parent.parent) |
46 | 46 |
|
47 | 47 | with pytest.raises(TypeError): |
48 | | - path = get_root([]) |
| 48 | + path = find_root([]) |
49 | 49 |
|
50 | 50 | with pytest.raises(TypeError): |
51 | | - path = get_root("", ["abs", "def", 42]) |
| 51 | + path = find_root("", ["abs", "def", 42]) |
52 | 52 |
|
53 | 53 |
|
54 | 54 | def test_set_root(): |
55 | 55 |
|
56 | | - path = get_root(__file__) |
| 56 | + path = find_root(__file__) |
57 | 57 | assert path.exists() |
58 | 58 |
|
59 | 59 | os.chdir(path.parent) |
60 | 60 | assert os.getcwd() != str(path) |
61 | 61 |
|
62 | | - with pytest.raises(Exception): |
63 | | - set_root(path, pythonpath=False, cwd=False, project_root_env_var=False, dotenv=False) |
64 | | - |
65 | 62 | assert "PROJECT_ROOT" not in os.environ |
66 | 63 |
|
67 | 64 | set_root(path, pythonpath=False, cwd=False, project_root_env_var=True, dotenv=False) |
|
0 commit comments