From 4030bd8d392a206d9020c45320b1f4c19597d1f9 Mon Sep 17 00:00:00 2001
From: markus holzer <markus.holzer@fau.de>
Date: Fri, 22 Jan 2021 16:46:02 +0100
Subject: [PATCH] Added test case for version number

---
 pystencils/__init__.py                  |  6 +++---
 pystencils_tests/test_version_string.py | 12 ++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
 create mode 100644 pystencils_tests/test_version_string.py

diff --git a/pystencils/__init__.py b/pystencils/__init__.py
index c74a03e17..d2abab709 100644
--- a/pystencils/__init__.py
+++ b/pystencils/__init__.py
@@ -22,16 +22,16 @@ except ImportError:
     pass
 
 
-def _get_file_path():
+def _get_release_file():
     import os.path
     file_path = os.path.abspath(os.path.dirname(__file__))
     return os.path.join(file_path, '..', 'RELEASE-VERSION')
 
 
 try:
-    __version__ = open(_get_file_path(), 'r').read()
+    __version__ = open(_get_release_file(), 'r').read()
 except IOError:
-    __version__ = 'Please install pystencils with setup.py'
+    __version__ = 'development'
 
 __all__ = ['Field', 'FieldType', 'fields',
            'TypedSymbol',
diff --git a/pystencils_tests/test_version_string.py b/pystencils_tests/test_version_string.py
new file mode 100644
index 000000000..541ba35e2
--- /dev/null
+++ b/pystencils_tests/test_version_string.py
@@ -0,0 +1,12 @@
+import pystencils as ps
+from pathlib import Path
+
+def test_version_string():
+    file_path = Path(__file__).parent
+    release_version = file_path.parent.absolute() / 'RELEASE-VERSION'
+    if release_version.exists ():
+        with open(release_version, "r") as f:
+            version = f.read()
+        assert ps.__version__ == version
+    else:
+        ps.__version__ == "development"
-- 
GitLab