From 1d59035df8ec4847bcbb160a856022c12a62678e Mon Sep 17 00:00:00 2001 From: Hari Date: Thu, 21 Mar 2024 11:37:41 +0100 Subject: [PATCH] added attribute __version__ --- pathfinding3d/__init__.py | 6 ++++++ test/test_version.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/test_version.py diff --git a/pathfinding3d/__init__.py b/pathfinding3d/__init__.py index 824ff04..1a3e37c 100644 --- a/pathfinding3d/__init__.py +++ b/pathfinding3d/__init__.py @@ -1 +1,7 @@ +import os + __all__ = ["core", "finder"] + +# read the version from version.txt +with open(os.path.join(os.path.dirname(__file__), "version.txt"), encoding="utf-8") as file_handler: + __version__ = file_handler.read().strip() diff --git a/test/test_version.py b/test/test_version.py new file mode 100644 index 0000000..cd3db53 --- /dev/null +++ b/test/test_version.py @@ -0,0 +1,16 @@ +import os + + +def test_version(): + """ + Test if __version__ is correctly read from version.txt + """ + from pathfinding3d import __version__ + + # Read the version from version.txt + with open( + os.path.join(os.path.dirname(os.path.dirname(__file__)), "pathfinding3d", "version.txt"), encoding="utf-8" + ) as file_handler: + version = file_handler.read().strip() + + assert __version__ == version