Package portage :: Package tests :: Package versions :: Module test_vercmp
[hide private]

Source Code for Module portage.tests.versions.test_vercmp

 1  # test_vercmp.py -- Portage Unit Testing Functionality 
 2  # Copyright 2006 Gentoo Foundation 
 3  # Distributed under the terms of the GNU General Public License v2 
 4   
 5  from portage.tests import TestCase 
 6  from portage.versions import vercmp 
 7   
8 -class VerCmpTestCase(TestCase):
9 """ A simple testCase for portage.versions.vercmp() 10 """ 11
12 - def testVerCmpGreater(self):
13 14 tests = [ 15 ("6.0", "5.0"), ("5.0", "5"), 16 ("1.0-r1", "1.0-r0"), 17 ("1.0-r1", "1.0"), 18 ("cvs.9999", "9999"), 19 ("999999999999999999999999999999", "999999999999999999999999999998"), 20 ("1.0.0", "1.0"), 21 ("1.0.0", "1.0b"), 22 ("1b", "1"), 23 ("1b_p1", "1_p1"), 24 ("1.1b", "1.1"), 25 ("12.2.5", "12.2b"), 26 ] 27 for test in tests: 28 self.assertFalse(vercmp(test[0], test[1]) <= 0, msg="%s < %s? Wrong!" % (test[0], test[1]))
29
30 - def testVerCmpLess(self):
31 """ 32 pre < alpha < beta < rc < p -> test each of these, they are inductive (or should be..) 33 """ 34 tests = [ 35 ("4.0", "5.0"), ("5", "5.0"), ("1.0_pre2", "1.0_p2"), 36 ("1.0_alpha2", "1.0_p2"), ("1.0_alpha1", "1.0_beta1"), ("1.0_beta3", "1.0_rc3"), 37 ("1.001000000000000000001", "1.001000000000000000002"), 38 ("1.00100000000", "1.0010000000000000001"), 39 ("9999", "cvs.9999"), 40 ("999999999999999999999999999998", "999999999999999999999999999999"), 41 ("1.01", "1.1"), 42 ("1.0-r0", "1.0-r1"), 43 ("1.0", "1.0-r1"), 44 ("1.0", "1.0.0"), 45 ("1.0b", "1.0.0"), 46 ("1_p1", "1b_p1"), 47 ("1", "1b"), 48 ("1.1", "1.1b"), 49 ("12.2b", "12.2.5"), 50 ] 51 for test in tests: 52 self.assertFalse(vercmp(test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0], test[1]))
53
54 - def testVerCmpEqual(self):
55 56 tests = [ 57 ("4.0", "4.0"), 58 ("1.0", "1.0"), 59 ("1.0-r0", "1.0"), 60 ("1.0", "1.0-r0"), 61 ("1.0-r0", "1.0-r0"), 62 ("1.0-r1", "1.0-r1") 63 ] 64 for test in tests: 65 self.assertFalse(vercmp(test[0], test[1]) != 0, msg="%s != %s? Wrong!" % (test[0], test[1]))
66
67 - def testVerNotEqual(self):
68 69 tests = [ 70 ("1", "2"), ("1.0_alpha", "1.0_pre"), ("1.0_beta", "1.0_alpha"), 71 ("0", "0.0"), 72 ("cvs.9999", "9999"), 73 ("1.0-r0", "1.0-r1"), 74 ("1.0-r1", "1.0-r0"), 75 ("1.0", "1.0-r1"), 76 ("1.0-r1", "1.0"), 77 ("1.0", "1.0.0"), 78 ("1_p1", "1b_p1"), 79 ("1b", "1"), 80 ("1.1b", "1.1"), 81 ("12.2b", "12.2"), 82 ] 83 for test in tests: 84 self.assertFalse(vercmp(test[0], test[1]) == 0, msg="%s == %s? Wrong!" % (test[0], test[1]))
85