Skip to content

Commit

Permalink
version tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Jun 5, 2024
1 parent bfdc823 commit 745b40f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ def test_get_ucx_version():
assert ucp.core._ctx is None


def test_git_commit_constant():
# __git_commit__ will only be non-empty in a built distribution
assert isinstance(ucp.__git_commit__, str)


def test_version_constant():
assert isinstance(ucp.__version__, str)

Expand Down
17 changes: 15 additions & 2 deletions ucp/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,18 @@

import importlib.resources

__version__ = importlib.resources.files("ucp").joinpath("VERSION").read_text().strip()
__git_commit__ = ""
__version__ = (
importlib.resources.files(__package__).joinpath("VERSION").read_text().strip()
)

try:
__git_commit__ = (
importlib.resources.files(__package__)
.joinpath("GIT_COMMIT")
.read_text()
.strip()
)
except FileNotFoundError:
__git_commit__ = ""

__all__ = ["__git_commit__", "__version__"]

0 comments on commit 745b40f

Please sign in to comment.