-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add git info and Python package info providers
They are classes with minimal state and a no-arguments `__call__()` operator, giving a dictionary of context values as required. Tests both providers in a lean unit test each.
- Loading branch information
1 parent
01486ce
commit 55a3767
Showing
3 changed files
with
122 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
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,24 @@ | ||
from nnbench.context import GitEnvironmentInfo, PythonPackageInfo | ||
|
||
|
||
def test_python_package_info() -> None: | ||
p = PythonPackageInfo("pre-commit", "pyyaml")() | ||
|
||
for v in p.values(): | ||
assert v != "" | ||
|
||
# for a bogus package, it should not fail but produce an empty string. | ||
p = PythonPackageInfo("asdfghjkl")() | ||
|
||
for v in p.values(): | ||
assert v == "" | ||
|
||
|
||
def test_git_info_provider() -> None: | ||
g = GitEnvironmentInfo()() | ||
|
||
# tag might not be available in a shallow checkout in CI, | ||
# but commit, provider and repo are. | ||
assert g["commit"] != "" | ||
assert g["provider"] == "github.com" | ||
assert g["repository"] == "aai-institute/nnbench" |