def test_upstream_cmp_basic(self): # equal self.assertEqual(upstream_cmp("0", "0"), 0) # first newer self.assertEqual(upstream_cmp("1", "0"), 1) # second newer self.assertEqual(upstream_cmp("0", "1"), -1)
def test_upstream_cmp_pre(self): self.assertEqual(upstream_cmp("4.0.0", "4.0.0"), 0) self.assertEqual(upstream_cmp("4.0.0", "4.0.0-pre1"), 1) self.assertEqual(upstream_cmp("4.0.0", "3.9.9-pre1"), 1) self.assertEqual(upstream_cmp("4.0.1-pre1", "4.0.0-pre1"), 1) self.assertEqual(upstream_cmp("4.0.1-pre1", "4.0.0"), 1) self.assertEqual(upstream_cmp("4.0.1pre1", "4.0.0"), 1) self.assertEqual(upstream_cmp("4.0.0", "4.0.0pre1"), 1) self.assertEqual(upstream_cmp("4.0.0-pre2", "4.0.0-pre1"), 1) self.assertEqual(upstream_cmp("4.0.0-pre2", "4.0.0pre1"), 1) self.assertEqual(upstream_cmp("4.0.0", "4.0.0-pre2"), 1) self.assertEqual(upstream_cmp("1.0.0", "1.0.0-pre1"), 1) self.assertEqual(upstream_cmp("1.0.0PRE1", "1.0.0pre1"), 0) self.assertEqual(upstream_cmp("1.0.0pre15", "1.0.0pre2"), 1) self.assertEqual(upstream_cmp("1.0pre5", "1.0pre05"), 0)
def test_upstream_cmp_rc(self): self.assertEqual(upstream_cmp("4.0.0", "4.0.0"), 0) self.assertEqual(upstream_cmp("4.0.0", "4.0.0-rc1"), 1) self.assertEqual(upstream_cmp("4.0.0", "4.0.0-RC1"), 1) self.assertEqual(upstream_cmp("4.0.0", "3.9.9-rc1"), 1) self.assertEqual(upstream_cmp("4.0.1-rc1", "4.0.0-rc1"), 1) self.assertEqual(upstream_cmp("4.0.1-rc1", "4.0.0"), 1) self.assertEqual(upstream_cmp("4.0.1-RC1", "4.0.0"), 1) self.assertEqual(upstream_cmp("4.0.1rc1", "4.0.0"), 1) self.assertEqual(upstream_cmp("4.0.1RC1", "4.0.0"), 1) self.assertEqual(upstream_cmp("4.0.0", "4.0.0rc1"), 1) self.assertEqual(upstream_cmp("4.0.0-rc2", "4.0.0-rc1"), 1) self.assertEqual(upstream_cmp("4.0.0-rc2", "4.0.0rc1"), 1) self.assertEqual(upstream_cmp("4.0.0", "4.0.0-rc2"), 1) self.assertEqual(upstream_cmp("1.0.0rc3", "1.0.0RC3"), 0) self.assertEqual(upstream_cmp("1.0.0", "1.0.0-rc1"), 1) self.assertEqual(upstream_cmp("1.0.0rc3", "1.0.0-RC21"), -1) self.assertEqual(upstream_cmp("1.0.0rc10", "1.0.0-rc0010"), 0)
def test_snapshot_version_with_dash(self): # first newer self.assertEqual(upstream_cmp("1.8.23-20100128-r1100", "1.8.23-20091230-r1079"), 1)