add the __version__ feature to the package
authorSalim Fadhley <sal@stodge.org>
Mon, 28 Jul 2014 22:36:48 +0000 (23:36 +0100)
committerSalim Fadhley <sal@stodge.org>
Mon, 28 Jul 2014 22:36:48 +0000 (23:36 +0100)
jenkinsapi/__init__.py
jenkinsapi_tests/unittests/test_misc.py [new file with mode: 0644]

index 9829b5aed901eb15f9b417629088111e20e11cd7..7f260e2289c6c44d9085c81c063a46ba73a4e2e0 100644 (file)
@@ -45,7 +45,7 @@ Project Authors
 Current code lives on github: https://github.com/salimfadhley/jenkinsapi
 
 """
-
+import pkg_resources
 from jenkinsapi import (
     # Modules
     command_line,
@@ -62,3 +62,5 @@ __all__ = [
     "fingerprint", "jenkins", "jenkinsbase", "job", "node", "result_set", "result", "view"
 ]
 __docformat__ = "epytext"
+__version__ = pkg_resources.working_set.by_key['jenkinsapi'].version
+
diff --git a/jenkinsapi_tests/unittests/test_misc.py b/jenkinsapi_tests/unittests/test_misc.py
new file mode 100644 (file)
index 0000000..3b77206
--- /dev/null
@@ -0,0 +1,17 @@
+import unittest
+import jenkinsapi
+
+
+class TestMisc(unittest.TestCase):
+    
+    def test_jenkinsapi_version(self):
+        """Verify that we can get the jenkinsapi version number from the
+        package's __version__ property.
+        """
+        v = jenkinsapi.__version__
+        parts = [int(x) for x in v.split('.')]
+        for p in parts:
+            assert p >= 0, "Implausible version number: %r" % v
+            
+if __name__ == '__main__':
+    unittest.main()
\ No newline at end of file