-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
00597b2
commit 5a812d9
Showing
2 changed files
with
26 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pathlib import Path | ||
from tempfile import NamedTemporaryFile | ||
|
||
from model2vec.utils import _get_metadata_from_readme | ||
|
||
|
||
def test__get_metadata_from_readme_not_exists() -> None: | ||
"""Test getting metadata from a README.""" | ||
assert _get_metadata_from_readme(Path("zzz")) == {} | ||
|
||
|
||
def test__get_metadata_from_readme_mocked_file() -> None: | ||
"""Test getting metadata from a README.""" | ||
with NamedTemporaryFile() as f: | ||
f.write(b"---\nkey: value\n---\n") | ||
f.flush() | ||
assert _get_metadata_from_readme(Path(f.name))["key"] == "value" | ||
|
||
|
||
def test__get_metadata_from_readme_mocked_file_keys() -> None: | ||
"""Test getting metadata from a README.""" | ||
with NamedTemporaryFile() as f: | ||
f.write(b"") | ||
f.flush() | ||
assert set(_get_metadata_from_readme(Path(f.name))) == set() |