[asterisk-commits] mnicholson: branch mnicholson/fancy-versions r2407 - /asterisk/team/mnicholso...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 22 12:18:18 CDT 2011
Author: mnicholson
Date: Thu Sep 22 12:18:12 2011
New Revision: 2407
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2407
Log:
added support for testing the branch of a particular asterisk version string
Modified:
asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/version.py
Modified: asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/version.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/version.py?view=diff&rev=2407&r1=2406&r2=2407
==============================================================================
--- asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/version.py (original)
+++ asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/version.py Thu Sep 22 12:18:12 2011
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# vim: et sw=4:
"""Asterisk Version String Handling
This module implements an Asterisk version string parser. It can also compare
@@ -155,8 +156,35 @@
sys.exc_info()[0]))
return v
+ def has_major_version(self, ver):
+ if ver == "trunk":
+ return self.branch == "trunk"
+ return self.branch == AsteriskVersion(ver).branch
+
class AsteriskVersionTests(unittest.TestCase):
+ def test_has_major_version(self):
+ v = AsteriskVersion("1.4.30")
+ self.assertTrue(v.has_major_version("1.4"))
+
+ v = AsteriskVersion("SVN-branch-1.6.2-r245581")
+ self.assertTrue(v.has_major_version("1.6.2"))
+
+ v = AsteriskVersion("1.8.0.1")
+ self.assertTrue(v.has_major_version("1.8"))
+
+ v = AsteriskVersion("1.6.2.18")
+ self.assertTrue(v.has_major_version("1.6.2"))
+
+ v = AsteriskVersion("10.0")
+ self.assertTrue(v.has_major_version("10"))
+
+ v = AsteriskVersion("SVN-trunk-r252849")
+ self.assertTrue(v.has_major_version("trunk"))
+
+ v = AsteriskVersion("10.0")
+ self.assertFalse(v.has_major_version("1.4"))
+
def test_version(self):
v = AsteriskVersion("1.4.30")
self.assertFalse(v.svn)
More information about the asterisk-commits
mailing list