|
1 | | -from pathlib import PurePosixPath |
| 1 | +from pathlib import Path |
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): |
9 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/my_project")): |
| 8 | + def test_simple_name(self, tmp_path: Path): |
| 9 | + with usethis_config.set(project_dir=tmp_path / "my_project"): |
10 | 10 | assert get_project_name_from_dir() == "my_project" |
11 | 11 |
|
12 | | - def test_leading_dot(self): |
13 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/.github-private")): |
| 12 | + def test_leading_dot(self, tmp_path: Path): |
| 13 | + with usethis_config.set(project_dir=tmp_path / ".github-private"): |
14 | 14 | assert get_project_name_from_dir() == "github-private" |
15 | 15 |
|
16 | | - def test_leading_dots(self): |
17 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/..hidden")): |
| 16 | + def test_leading_dots(self, tmp_path: Path): |
| 17 | + with usethis_config.set(project_dir=tmp_path / "..hidden"): |
18 | 18 | assert get_project_name_from_dir() == "hidden" |
19 | 19 |
|
20 | 20 | def test_trailing_dot(self): |
21 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/project.")): |
| 21 | + with usethis_config.set(project_dir="/fake/project."): |
22 | 22 | assert get_project_name_from_dir() == "project" |
23 | 23 |
|
24 | | - def test_leading_and_trailing_non_alphanumeric(self): |
25 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/-_project_-")): |
| 24 | + def test_leading_and_trailing_non_alphanumeric(self, tmp_path: Path): |
| 25 | + with usethis_config.set(project_dir=tmp_path / "-_project_-"): |
26 | 26 | assert get_project_name_from_dir() == "project" |
27 | 27 |
|
28 | 28 | def test_only_dots(self): |
29 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/...")): |
| 29 | + with usethis_config.set(project_dir="/fake/..."): |
30 | 30 | assert get_project_name_from_dir() == "hello_world" |
31 | 31 |
|
32 | | - def test_no_valid_chars(self): |
33 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/+")): |
| 32 | + def test_no_valid_chars(self, tmp_path: Path): |
| 33 | + with usethis_config.set(project_dir=tmp_path / "+"): |
34 | 34 | assert get_project_name_from_dir() == "hello_world" |
35 | 35 |
|
36 | | - def test_drops_invalid_chars(self): |
37 | | - with usethis_config.set(project_dir=PurePosixPath("/fake/h-e+l.l_o")): |
| 36 | + def test_drops_invalid_chars(self, tmp_path: Path): |
| 37 | + with usethis_config.set(project_dir=tmp_path / "h-e+l.l_o"): |
38 | 38 | assert get_project_name_from_dir() == "h-el.l_o" |
0 commit comments