Commits

ta...@MacZiade  committed 8e889f4

added Setuptools use cases

  • Participants
  • Parent commits 80be093
  • Branches tarek-postdev

Comments (0)

Files changed (2)

File test_verlib.py

         self.assertEquals(suggest('1.0rc2'), '1.0c2')
         self.assertEquals(suggest('walla walla washington'), None)
 
+        # from setuptools
+        self.assertEquals(suggest('0.4a1.r10'), '0.4a1.post10')
+        self.assertEquals(suggest('0.7a1dev-r66608'), '0.7a1.dev66608')
+        self.assertEquals(suggest('0.6a9.dev-r41475'), '0.6a9.dev41475')
+        self.assertEquals(suggest('2.4preview1'), '2.4c1')
+        self.assertEquals(suggest('2.4rc1'), '2.4c1')
+        self.assertEquals(suggest('2.4pre1') , '2.4c1')
+        self.assertEquals(suggest('2.1-rc2'), None)         # no suggestion
+
 def test_suite():
     README = os.path.join(os.path.dirname(__file__), 'README.txt')
     suite = [doctest.DocFileSuite(README), unittest.makeSuite(VersionTestCase)]
 
     # part of this could use maketrans
     for orig, repl in (('-alpha', 'a'), ('-beta', 'b'), ('alpha', 'a'),
-                       ('beta', 'b'), ('rc', 'c'), ('-', '.'),
+                       ('beta', 'b'), ('rc', 'c'),
                        ('+', '.'), ('_', '.'), (' ', ''), ('.final', ''),
                        ('final', '')):
         rs = rs.replace(orig, repl)
     # PyPI stats: 245 (7.56%) better
     rs = re.sub(r"(\d+[abc])$", r"\g<1>0", rs)
 
+    # the 'dev-rNNN' tag is a dev tag
+    rs = re.sub(r"\.?(dev-r|dev\.r)\.?(\d+)$", r".dev\2", rs)
+
+    # The 'r' and the '-' tags are post release tags
+    #   0.4a1.r10       ->  0.4a1.post10
+    #   0.9.33-17222    ->  0.9.3.post17222
+    #   0.9.33-r17222   ->  0.9.3.post17222
+    rs = re.sub(r"\.?(r|-|-r)\.?(\d+)$", r".post\2", rs)
+
     # Clean 'r' instead of 'dev' usage:
-    #   0.4a1.r10       ->  0.4a1.dev10
     #   0.9.33+r17222   ->  0.9.3.dev17222
     #   1.0dev123       ->  1.0.dev123
     #   1.0.git123      ->  1.0.dev123
     #   1.0.bzr123      ->  1.0.dev123
     #   0.1a0dev.123    ->  0.1a0.dev123
     # PyPI stats:  ~150 (~4%) better
-    rs = re.sub(r"\.?(r|dev|git|bzr)\.?(\d+)$", r".dev\2", rs)
+    rs = re.sub(r"\.?(dev|git|bzr)\.?(\d+)$", r".dev\2", rs)
 
     # Clean '.pre' (normalized from '-pre' above) instead of 'c' usage:
     #   0.2.pre1        ->  0.2c1