Provide a __str__ method

master
Mike Gerber 10 years ago
parent 790cfe7751
commit c3ecdeb767

@ -12,6 +12,9 @@ class Version(object):
def __init__(self, version_str): def __init__(self, version_str):
self.version_str = version_str self.version_str = version_str
def __str__(self):
return self.version_str
def components(self): def components(self):
return re.split('\.|-', self.version_str) return re.split('\.|-', self.version_str)

@ -40,6 +40,9 @@ class RunningKernelVersionTestCase(unittest.TestCase):
class VersionTestCase(unittest.TestCase): class VersionTestCase(unittest.TestCase):
def testStr(self):
self.assertEqual(str(Version('1.0')), '1.0')
def testComparingTrivial(self): def testComparingTrivial(self):
self.assertEqual(Version('1.0'), Version('1.0')) self.assertEqual(Version('1.0'), Version('1.0'))
self.assertGreater(Version('2.0'), Version('1.0')) self.assertGreater(Version('2.0'), Version('1.0'))

Loading…
Cancel
Save