|
1 | | -from pathlib import Path |
| 1 | +from pathlib import PurePosixPath |
2 | 2 |
|
3 | 3 | from usethis._config import usethis_config |
4 | 4 | from usethis._file.dir import get_project_name_from_dir |
5 | 5 |
|
6 | 6 |
|
7 | 7 | class TestGetProjectNameFromDir: |
8 | | - def test_simple_name(self, tmp_path: Path): |
9 | | - path = tmp_path / "my_project" |
10 | | - path.mkdir() |
11 | | - with usethis_config.set(project_dir=path): |
| 8 | + def test_simple_name(self): |
| 9 | + with usethis_config.set(project_dir=PurePosixPath("/fake/my_project")): |
12 | 10 | assert get_project_name_from_dir() == "my_project" |
13 | 11 |
|
14 | | - def test_leading_dot(self, tmp_path: Path): |
15 | | - path = tmp_path / ".github-private" |
16 | | - path.mkdir() |
17 | | - with usethis_config.set(project_dir=path): |
| 12 | + def test_leading_dot(self): |
| 13 | + with usethis_config.set(project_dir=PurePosixPath("/fake/.github-private")): |
18 | 14 | assert get_project_name_from_dir() == "github-private" |
19 | 15 |
|
20 | | - def test_leading_dots(self, tmp_path: Path): |
21 | | - path = tmp_path / "..hidden" |
22 | | - path.mkdir() |
23 | | - with usethis_config.set(project_dir=path): |
| 16 | + def test_leading_dots(self): |
| 17 | + with usethis_config.set(project_dir=PurePosixPath("/fake/..hidden")): |
24 | 18 | assert get_project_name_from_dir() == "hidden" |
25 | 19 |
|
26 | | - def test_trailing_dot(self, tmp_path: Path): |
27 | | - path = tmp_path / "project." |
28 | | - path.mkdir() |
29 | | - with usethis_config.set(project_dir=path): |
| 20 | + def test_trailing_dot(self): |
| 21 | + with usethis_config.set(project_dir=PurePosixPath("/fake/project.")): |
30 | 22 | assert get_project_name_from_dir() == "project" |
31 | 23 |
|
32 | | - def test_leading_and_trailing_non_alphanumeric(self, tmp_path: Path): |
33 | | - path = tmp_path / "-_project_-" |
34 | | - path.mkdir() |
35 | | - with usethis_config.set(project_dir=path): |
| 24 | + def test_leading_and_trailing_non_alphanumeric(self): |
| 25 | + with usethis_config.set(project_dir=PurePosixPath("/fake/-_project_-")): |
36 | 26 | assert get_project_name_from_dir() == "project" |
37 | 27 |
|
38 | | - def test_only_dots(self, tmp_path: Path): |
39 | | - path = tmp_path / "..." |
40 | | - path.mkdir() |
41 | | - with usethis_config.set(project_dir=path): |
| 28 | + def test_only_dots(self): |
| 29 | + with usethis_config.set(project_dir=PurePosixPath("/fake/...")): |
42 | 30 | assert get_project_name_from_dir() == "hello_world" |
43 | 31 |
|
44 | | - def test_no_valid_chars(self, tmp_path: Path): |
45 | | - path = tmp_path / "+" |
46 | | - path.mkdir() |
47 | | - with usethis_config.set(project_dir=path): |
| 32 | + def test_no_valid_chars(self): |
| 33 | + with usethis_config.set(project_dir=PurePosixPath("/fake/+")): |
48 | 34 | assert get_project_name_from_dir() == "hello_world" |
49 | 35 |
|
50 | | - def test_drops_invalid_chars(self, tmp_path: Path): |
51 | | - path = tmp_path / "h-e+l.l_o" |
52 | | - path.mkdir() |
53 | | - with usethis_config.set(project_dir=path): |
| 36 | + def test_drops_invalid_chars(self): |
| 37 | + with usethis_config.set(project_dir=PurePosixPath("/fake/h-e+l.l_o")): |
54 | 38 | assert get_project_name_from_dir() == "h-el.l_o" |
0 commit comments