-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
from pathlib import Path | ||
|
||
from conjector import properties | ||
|
||
|
||
@pytest.fixture | ||
def path_class_fixt(request): | ||
@properties(filename=request.param, root="path") | ||
class PathClass: | ||
str_file_path_var: Path | ||
str_dir_path_var: Path | ||
missing_path_var: Path | ||
|
||
return PathClass | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path_class_fixt", | ||
("types_cast.yml", "types_cast.json", "types_cast.toml", "types_cast.ini"), | ||
indirect=True, | ||
) | ||
def test_path_field_ok(path_class_fixt): | ||
assert path_class_fixt.str_file_path_var == Path("some/path/file.txt") | ||
assert path_class_fixt.str_dir_path_var == Path("some/file/") | ||
assert path_class_fixt.missing_path_var == Path() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"filename", | ||
("types_cast.yml", "types_cast.json", "types_cast.toml", "types_cast.ini"), | ||
) | ||
def test_invalid_path_field(filename): | ||
with pytest.raises(ValueError): | ||
|
||
@properties(filename=filename, root="path") | ||
class InvalidPathClass: | ||
invalid_path_var: Path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters